pernest Posted January 24, 2010 Share Posted January 24, 2010 Hello again. I'm having some problems resizing images. I have a script that allows users to upload images to the server, I then resize them to a standard size and attach them to an email. Everything works wonderfully until I try using large images, then I get an error about using to much memory. In order to resize the images, I'm using the function createimagefromjpeg, which seems to be a total memory hog (large images lots of memory, I know, I kmow). I have increased the memory limit for the script in php.ini, but my host wont allow me to increase it enough to deal with the sizes of images that I need to. I've tried using the exec function to pass the job on to the linux command 'convert', but this seems to be one of the many commands unavailable on my host. I was thinking of using curl to send the images to a third party site to have them converted, but including this step is likely to make my script very unreliable. Does anyone have any suggestions, as I've run out of ideas. Link to comment https://forums.phpfreaks.com/topic/189577-resizing-images/ Share on other sites More sharing options...
teamatomic Posted January 24, 2010 Share Posted January 24, 2010 Limit the upload size on the users end. If using upload_max_filesize remember that the value is the combined files size. So if you allow multiple file to be uploads the combined sizes must not exceed the max. So sometimes it is better to just tell the user what the size limit is then use the script. http://www.w3schools.com/PHP/php_file_upload.asp HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/189577-resizing-images/#findComment-1000630 Share on other sites More sharing options...
pernest Posted January 24, 2010 Author Share Posted January 24, 2010 Two points: 1) I need help to allow me to deal with larger images. 2) The code you refer me to is server side. The files get uploaded first before the script can check their size. Limit the upload size on the users end. If using upload_max_filesize remember that the value is the combined files size. So if you allow multiple file to be uploads the combined sizes must not exceed the max. So sometimes it is better to just tell the user what the size limit is then use the script. http://www.w3schools.com/PHP/php_file_upload.asp HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/189577-resizing-images/#findComment-1000766 Share on other sites More sharing options...
jl5501 Posted January 24, 2010 Share Posted January 24, 2010 Restricting the image size before upload is an issue with all current implementations. Javascript is not allowed to look at the local filesystem for security reasons so that is not an option. There are some flash based uploders that can do this, and also the hidden form field with name MAX_FILE_SIZE and its value set to the number of bytes of your intended maximum is supposed to work, but very unreliable and not implemented in all browsers. As far as resizing on the server is concerned, I always use phpThumb for this, which is very versatile. It can use the GD library, if installed on the server, or can use ImageMagick, again if installed. ImageMagick is generally the most memory efficient approach to this, and phpThumb is normally configured to look for ImageMagick first. Hope some of that will be helpful Link to comment https://forums.phpfreaks.com/topic/189577-resizing-images/#findComment-1000769 Share on other sites More sharing options...
pernest Posted January 24, 2010 Author Share Posted January 24, 2010 Thanks very much jl5501, unfortunately my host doesn't have imagemagick installed, and it seems that the GD library is just as memory hungry as imagecreatefromjpeg, so no joy there. Nice try, I will be using phpthumbs from now on for all my smaller image needs. Thanks again Link to comment https://forums.phpfreaks.com/topic/189577-resizing-images/#findComment-1000811 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.