Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

Distorted GIF files after Resize - shows black areas

images php coding issues or problems here.

Moderators: macek, egami, gesf

Distorted GIF files after Resize - shows black areas

Postby benhenny » Thu Jun 09, 2005 9:08 pm

My script resizes JPGs just fine, but when it comes to GIFs, it jacks them up.

I use imageCreateFromGif() to open the GIF, then I resize it and use imageCopyResampled() and imageJpeg() to create a JPG out of it. But when I do, it resizes it and creates the JPG, but it also adds noise to the image in the form of black pixelization in various areas of the image.

Any ideas?

Thanks!

Ken
User avatar
benhenny
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jun 09, 2005 9:02 pm
Location: Wisconsin

Solution: Convert GIF to JPG FIRST

Postby benhenny » Fri Jun 10, 2005 7:27 am

Thanks for all the feedback, but I figured it out myself. As with resampling images outside of PHP, you have to convert it to JPG first, then resize it:

Code: Select all
if ($file_name_extension == 'gif')
{
  $im_old = imageCreateFromGif($file_path);
  imageJpeg($im_old,$file_path,100);
  $im_old = imageCreateFromJpeg($file_path);
}
else if($file_name_extension == 'jpg')
{
  $im_old = imageCreateFromJpeg($file_path);
}
[/code]
User avatar
benhenny
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jun 09, 2005 9:02 pm
Location: Wisconsin


Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron