Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Take images OUT of the database - creating img hard copies

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #11  
Old 06-13-2003, 08:57 AM
 
smileyzoo smileyzoo is offline
 

Newbie
  
Join Date: Jun 2003
Posts: 2
 

Default Warning: imagecreatefromjpeg not a valid jpeg file...

Thanks for the code, usermike - it works great until it hits certain files - I don't know if they're corrupt, non-jpeg, etc. but at least on HAS the jpg ext.

Questions:
1. Is there way to work around this so that it processes the rest of the images? I modified the code (see below) and now get a similar series of errors on png...
2. I want to post all images to a directory rather than to a db from now on. I have been testing in skin1/main/product_modify.php - are there any other files affected?

Thanks for your help... smileyzoo

/* code to include imagecreatefrompng

function thumbnail($image_path,$thumb_path,$image_name,$thu mb_width)
{

if ($image_type =="image/pjpeg") {
$src_img = imagecreatefromjpeg("$image_path/$image_name");
$origw=imagesx($src_img);
$origh=imagesy($src_img);
$new_w = $thumb_width;
$diff=$origw/$new_w;
$new_h=$origh/$diff;
$dst_img = imagecreate($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w, $new_h,imagesx($src_img),imagesy($src_img));
//change 100 to something smaller for a smaller file size, lower quality image
imagejpeg($dst_img, "$thumb_path/$image_name", 100);
return true;
} else {
$src_img = imagecreatefrompng("$image_path/$image_name");
$origw=imagesx($src_img);
$origh=imagesy($src_img);
$new_w = $thumb_width;
$diff=$origw/$new_w;
$new_h=$origh/$diff;
$dst_img = imagecreate($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w, $new_h,imagesx($src_img),imagesy($src_img));
//change 100 to something smaller for a smaller file size, lower quality image
imagepng($dst_img, "$thumb_path/$image_name", 100);
return true;
}
}
*/
Reply With Quote
  #12  
Old 06-17-2003, 08:34 PM
 
usermike usermike is offline
 

Advanced Member
  
Join Date: Jan 2003
Posts: 41
 

Default

smileyzoo, there is a way to modify it, however it will take some time. How many images are you talking about? A lot?
Reply With Quote
  #13  
Old 06-18-2003, 04:16 AM
 
smileyzoo smileyzoo is offline
 

Newbie
  
Join Date: Jun 2003
Posts: 2
 

Default Copying images from MySQL to directory

Approx 2000-3000 images total.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:50 AM.

   

 
X-Cart forums © 2001-2020