[PHP] Re: imagecreatefromjpeg() uses too much memory
You didn't say, but, I assume that ordinary users will not be uploading to your web hotel. Thus To cope with the file size you must preprocess your images in an image editor, [e.g., PhotoShop, PaintShop Pro, etc.]. Enhance and compress as necessary. In general, it is best to use an image editor so you can visually judge the quality at each step. Are the images going to be displayed on your site? If so, I can't imagine needing anywhere near 16mb for a quality rendering. In general, GD2 does a poor job of processing quality images. It's great for annotating and applying borders, etc. Imagemagick is far superior for image processing. Then Fredrik Enestad wrote: Hi! I'm making a function for uploading and resizing images to my web hotel. Problem is, memory_limit is set to 16M so when uploading larger images the script crashes. So, I tried to override the memory_limit setting, but as it turns out, my web host has set some safe mode setting, so that no settings can be changed in the php.ini, and they wont change the setting to a higher value themselves. This is were the code crashes: $image_p = imagecreatetruecolor($widthNew, $heightNew); if($mime=="image/jpeg" || $mime=="image/pjpeg") { $image = imagecreatefromjpeg($imgarray["tmp_name"]); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $widthNew, $heightNew, $widthOrg, $heightOrg); imagejpeg($image_p, $save_dir.$temp_filename, 80); return "Done"; } The line $image = imagecreatefromjpeg($imgarray["tmp_name"]); causes the problem. Do any of you know any other way to solve this problem? -- Thanks Fredrik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: imagecreatefromjpeg
I think you'll want to use the 'imagecopyresized' function. Something like this: $thumbnail = imagecreate(100, 100); $original = imagecreatefromjpeg("uploadedfile.jpg"); imagecopyresized($thumbnail, $original, 0, 0, 0, 0, 100, 100, imagesx($original), imagesy($original)); imagejpeg($thumbnail, "thumb.jpg"); That would create a 100x100 thumbnail image with no scaling, but you get the idea! I do have the code that returns the uploaded image filename somewhere, and I'll hunt that out if you like. Thanks Richard -Original Message- From: Todd Cary [mailto:[EMAIL PROTECTED] Sent: 05 April 2004 15:54 To: [EMAIL PROTECTED] Subject: [PHP] Re: imagecreatefromjpeg Jason - I would like to give users the ability to upload jpeg images and have my php app size them into thumbnails as well as have a larger image available if the thumbnail is clicked. Are there examples of this available? Todd Jason Barnett wrote: > From http://www.php.net/manual/en/function.imagecreatefromjpeg.php > > To all those having trouble with a message to the effect of: > CreateImageFromJpeg() not supported in this PHP build > Start by adding --with-jpeg-dir to your ./configure options as I left > this out (not knowing I needed it) and I spent the best part of 6 hours > trying to compile to get this option. (RH 6.2, PHP 4.0.1pl2, Apache > 1.3.12, GD 1.8.3) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php == This message is for the sole use of the intended recipient. If you received this message in error please delete it and notify us. If this message was misdirected, CSFB does not waive any confidentiality or privilege. CSFB retains and monitors electronic communications sent through its network. Instructions transmitted over this system are not binding on CSFB until they are confirmed by us. Message transmission is not guaranteed to be secure. == -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: imagecreatefromjpeg
Jason - I would like to give users the ability to upload jpeg images and have my php app size them into thumbnails as well as have a larger image available if the thumbnail is clicked. Are there examples of this available? Todd Jason Barnett wrote: From http://www.php.net/manual/en/function.imagecreatefromjpeg.php To all those having trouble with a message to the effect of: CreateImageFromJpeg() not supported in this PHP build Start by adding --with-jpeg-dir to your ./configure options as I left this out (not knowing I needed it) and I spent the best part of 6 hours trying to compile to get this option. (RH 6.2, PHP 4.0.1pl2, Apache 1.3.12, GD 1.8.3) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: imagecreatefromjpeg
From http://www.php.net/manual/en/function.imagecreatefromjpeg.php To all those having trouble with a message to the effect of: CreateImageFromJpeg() not supported in this PHP build Start by adding --with-jpeg-dir to your ./configure options as I left this out (not knowing I needed it) and I spent the best part of 6 hours trying to compile to get this option. (RH 6.2, PHP 4.0.1pl2, Apache 1.3.12, GD 1.8.3) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: imagecreatefromjpeg
Bruno Santos wrote: Hello all. Im developing a page, and need to create a thumb of some images. i've compiled PHP 4.3.5 with the built-in support of GD, even having installed the GD library. the problem is that i call the imagecreatefromjpeg function, and PHP returns a fatal error when in run time i've even call the phpinfo function to see the php variables, and there shows that the support of GD is avaiable can someone tell me why this is hapening ? Hmmm, do you have the extension uncommented in your php.ini? here's the error *Fatal error*: Call to undefined function: imagecreatefromjpeg() in */usr/local/apache2/htdocs/projecto/examples/uploadimg.php regards * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php