Page 1 of 1

png (and gif?) to jpeg thumbnail

Posted: Fri May 20, 2005 3:09 pm
by Skara
First, is there an easy way to convert a png to a jpeg?
I don't want the original as such, I just want to make a thumbnail for it.

Second, I know that gifs are copyrighted, but frankly I don't care. :P Is there a way to get a thumbnail from these too?

Posted: Fri May 20, 2005 3:17 pm
by Burrito
I haven't tried it, but seems like you could use imagecreatefrom%whatevertype%() and then use imageJPEG() to generate the image in a jpg format:

Code: Select all

$img = imagecreatefromgif("yourpath/yourimage.gif");
$width=imagesx($img);$height=imagesy($img); 
$thumb_Width=100;
$thumb_Height=75;
$scale = min($thumb_Width/$width, $thumb_Height/$height); 
$new_width=floor($scale*$width);
$new_height=floor($scale*$height); 
$tmp_img=imagecreatetruecolor($new_width,$new_height); 
imagecopyresampled($tmp_img,$img,0,0,0,0,$new_width,$new_height,$width,$height); 
imagedestroy($img); 
imageJPEG($tmp_img, "yourpath/yourimage.jpg");

Posted: Fri May 20, 2005 3:27 pm
by anjanesh
Since PHP 4.3.9 (or 4.3.10 ?) gif support was included (since that version of bundled GD) - so I guess copyright issues wont come into place now.

1. imagecreatefrompng

2. imagegif

Posted: Fri May 20, 2005 3:28 pm
by Burrito
you piqued my interest so I just tested it and it worked...

Re: png (and gif?) to jpeg thumbnail

Posted: Fri May 20, 2005 3:45 pm
by Roja
Skara wrote: Second, I know that gifs are copyrighted, but frankly I don't care. :P Is there a way to get a thumbnail from these too?
Since the original question was answered, I wanted to throw in a quick correction here..

You meant they were patented, not copyrighted.

And until last year, when the patents expired, you would very much care if unisys came to you and told you to pay thousands for your use on "tiny-website.com", which is exactly what they did to several sites and companies.

Thankfully, that patent expired. Know the risks, and steer clear. :)

Knowledge is power!

Posted: Fri May 20, 2005 3:47 pm
by Skara
haha, guess it's time to update then. :P Still on 4.3.4