Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Album Art

Featured Replies

Okay, so I'm making a music review site and want to sort out the way images for albums are stored. So firstly, I'm guessing I will have a field in the "album" table called "imgpath" and that will contain something like "images/32/dsfx.jpg". But what I want to know is how I would go about having a form where the user chooses an image from their computer, the script will then take this image, resize it to 300x300 and put it inside a folder and then will create a "thumbnail" version of the image at 60x60 and put it in a different folder. I've got no idea where to start with this, a google search didn't provide much help and I want to know I'm doing it the right way so any help would be greatly appreciated!

Hey,

 

What are your skills like and which language do you plan on using?

 

If its PHP then I can help and provide some examples for you but I'm not going to type and essay to find out you don't use PHP :p

  • Author
Hey,

 

What are your skills like and which language do you plan on using?

 

If its PHP then I can help and provide some examples for you but I'm not going to type and essay to find out you don't use PHP :p

Thanks for your help :p

I'm using PHP and mySQL at the moment. I know I've got the correct image libraries installed on my server so that's all cool.

 

All I need help with is uploading an image and then converting it into two sizes (one full album, one thumbnail) with a random name (something like xfgh3sdh38.jpg) so that none of the names overlap.

 

I'd really appreciate any help :)

If your web-server has the Image Magick module installed you can use that do do things like resizing images. Although the results are not as good as you would get doing it by hand with something like Photoshop Elements.

Here is a link to the website for this module: Image Magick

You may need to find a book with a tutorial to give you step-by-step instructions, but you will also need to follow that link to get details of what the parameters do.

 

There is a newer graphics package for PHP called gd (apparently) but I have never used it.

phpThumb is your friend here

 

http://phpthumb.sourceforge.net/

 

phpThumb can cache the images at different sizes so they are only generated once, keeping server load down. This gives you the flexibility of being able to change the thumb size on the fly.

 

If you were to have it generate resized files at upload, then change your design to one that requires a thumb at 100px wide, you'd have alot of work to do to resize 1000's of images.

 

The way you request the images is bascially:

<img src="phpThumb.php?src=images/23423r23423.jpg&w=70" />

With w=70 being the width in pixels.

 

For info on assigning a random filename see linky

 

Have fun :)

  • Author

Thanks for the help guys. I'm gonna have a sit down and check all that stuff out when I get a chance and hopefully get something working! I'll post back here if I run into any troubles

  • Author

So I've gotten a little further. My users are able to upload a picture when they create a new artist on my site. I don't have any problems storing the picture, I'm only having troubles resizing it to 300x300. Here's the code I'm using:

 

$artistart = $HTTP_POST_FILES['image'];

 

if ($artistart['type'] == 'image/jpeg') {

 

$tempimg = $artistart['tmp_name'];

 

$tempsize = getimagesize($tempimg);

 

$width = $tempsize['0'];

$height = $tempsize['1'];

 

$newwidth = 300;

$newheight = 300;

 

$uniq = uniqid("");

 

$filename = DOCUMENT_ROOT . 'artistart/'.$uniq . '.jpg';

 

$thumb = imagecreatetruecolor($newwidth, $newheight);

 

$source = imagecreatefromjpeg($tempimg);

 

imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

 

return imagejpeg($thumb,$filename);

 

}

 

 

When I do this, I get a bunch of very odd (and long) code appear across the screen instead of the image I want. Can anyone help??

 

Thanks in advance!

You need to output the correct header to tell the browser that its not an HTML page, its an image.

header('Content-Type: image/jpeg');

 

Make sure the image stuff is in its own file as well. You would then do somethign like this or similar in your main html.

<img src="yourimage.php?id=23" alt="" />

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.