Jump to content
xisto Community
Sign in to follow this  
FirefoxRocks

Phpthumb

Recommended Posts

I have downloaded phpThumb and it works correctly right now. I have a problem with implementing this on a project which has LARGE jpegs on it.

 

Here is the error message:

 

phpThumb() v1.7.9-200805132119Source image is too large (3456*2592 = 9.0Mpx, max 5.6Mpx) for GD creation(either install ImageMagick or increase PHP memory_limit to at least 48M).

I have come up with 3 solutions but they aren't suitable or are too time-consuming to implement.

Increase PHP memory_limit to at least 48M.

I can't do this because I do not have access to this and I don't think that the server can handle it.

Install ImageMagick

Again I do not have permission to do this and I also don't know how to.

Resize every image to 50% of their high-resolution size.

This is much too time consuming as there are almost 300 images and even with Microsoft Office Picture Manager, the file operations take a long time. And I would also have to upload all of the new images to the server.

Right now I have used CSS dimension properties to squish the images into 200px width table cells, but this isn't a thumbnail and it still takes very long for all the images to display, even with a fast Internet connection (and even on the server itself).

 

Is there a possible way to make PHP thumbnails without modifying server settings?

Edited by FirefoxRocks (see edit history)

Share this post


Link to post
Share on other sites

1.

ini_set('memory_limit', '48M');//Do your thingini_restore('memory_limit');

2. Ask the host

3. You could use GD to resize the image, however memory constraints may prevent this as well.

Those are the options you could possibly take.

Cheers,

MC

Share this post


Link to post
Share on other sites

1.

ini_set('memory_limit' '48M');//Do your thingini_restore('memory_limit');
I tried that, kept failing until I realized you forgot a comma in the first function. Didn't work, a blank image came up.

2. Ask the host

That failed.

3. You could use GD to resize the image, however memory constraints may prevent this as well.
Those are the options you could possibly take.

Cheers,

MC

Well I have to keep trying, so how do I do that?

FirefoxRocks

Share this post


Link to post
Share on other sites

There are options of course. Your best bet is likely going to be to re-size the images though. The best to so do from what I am reading is to set up the images to re-size via a script in an image editing program that allows you to do so. Photoshop, for instance, has the ability to run scripts for many things. It is possible to have the application open re-size and save all of the images in a specified folder. Though it may take some time given the variables invovled it would be automatic. I am fairly certain there are other programs with this ability as well if Photoshop is not an option. In truth I really can not imagine why you would need a jpeg image of that size. The optimum resolution on a 30" Apple monitor is only 2560 x 1600 for example. If the image is at a high resolution for the sake of printing jpeg is not the ideal format. Regardless accepting that for what ever reason those visiting your site need a jpeg at this resolution you would likely be better off to provide a preview image and provide the fulll resolution images via download.

Share this post


Link to post
Share on other sites

I would also go with resizing your images, as they're probably too huge for web consumption.

If you're going to use GD to resize your images, you should probably set up a server on your own computer where you can change the memory constraints for php without having to bother the webhost. I think if you take a look at php's page for its gd function imagecopyresized you'll see how to resize them. :)

I also have this piece of code that I used to resize images with gd on a gallery:

function createthumb($name,$filename,$new_w,$new_h) {		$system=explode(".",$name);		if ("jpg" == $system[1]){$src_img=imagecreatefromjpeg($name);}		if ("png" == $system[1]){$src_img=imagecreatefrompng($name);}		else			$src_img=imagecreatefromjpeg($name);		$old_x=imageSX($src_img);		$old_y=imageSY($src_img);		if ($old_x > $old_y) 		{			$thumb_w=$new_w;			$thumb_h=$old_y*($new_h/$old_x);		}		if ($old_x < $old_y) 		{			$thumb_w=$old_x*($new_w/$old_y);			$thumb_h=$new_h;		}		if ($old_x == $old_y) 		{			$thumb_w=$new_w;			$thumb_h=$new_h;		}		$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);		imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 		if (preg_match("/png/",$system[1]))		{			imagepng($dst_img,$filename); 		} else {			imagejpeg($dst_img,$filename); 		}		imagedestroy($dst_img); 		imagedestroy($src_img); 	}
This one is using imagecreatetruecolor and imagecopyresampled instead of the other function I mentioned above. I'm not sure which one is better; I've never explicitly compared the two.

I have no idea if Photoshop has macros, but I'm sure you could also just write a quick macro script with autohotkey (https://www.autohotkey.com/) and run it with any image editing program you want. Then just leave the computer on for some time and just let your image program resize the images. I'd personally prefer the php method since you can actually stay at your computer. :P

EDIT: Oops, I forgot. If you just install php on your computer, you should be able to run phpthumb on your computer, resize the images and not have to worry about memory constraints, right? Then you won't have to worry about custom-writing an image resizing function.
Edited by Arbitrary (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.