Page 1 of 1

Imagemagick and Stockboxphoto

Posted: 2012-05-08T08:47:30-07:00
by Valaraukr
Hi I am trying to use stockbox photo to sell digital images. The software uses imagemagick to resize images but i keep on using up all the memory on my server while trying to convert. Is there a way of configuring imagemagick and then installing it so that it uses disk space instead of RAM to cache the images. As I am very new to imagemagick any help would be appreciated.

Many Thanks

Re: Imagemagick and Stockboxphoto

Posted: 2012-05-08T09:12:51-07:00
by magick
Set memory limits in the policy.xml configuration file. You might, for example, set it to 1GB. Any image that consumes more than 1GB's is automatically cached to disk. See http://www.imagemagick.org/script/resources.php.

Re: Imagemagick and Stockboxphoto

Posted: 2012-05-08T09:39:51-07:00
by Valaraukr
Could you tell me where to find this file and also how to change the parameters?

Many thanks

Re: Imagemagick and Stockboxphoto

Posted: 2012-05-09T11:56:57-07:00
by Valaraukr
Hi,

I believe the reason it is taking up so much memory is because it has to generate individual download files for royalty free products of which are can be a maximum of 8 and that is what is taking up so much of the memory.

I think the software asks imagemagick to render all the download files simultaneusly rather one by one in sequence? Can you set the maximum number of executions at one time to 1 so it goes through them sequentially.

many thanks

Re: Imagemagick and Stockboxphoto

Posted: 2012-05-09T13:13:20-07:00
by fmw42
what is the command line you are using. If you are calling convert on all the images at the same time, it will run out of memory as it tries to process them all. In stead, you can use mogrify to process each image in a directory one at a time. see http://www.imagemagick.org/Usage/basics/#mogrify

Re: Imagemagick and Stockboxphoto

Posted: 2012-05-10T04:13:21-07:00
by Valaraukr
HI

What stockbox is doing is taking a file and making 8 files of different sizes from the original. It is saving them in the same directory but putting a prefix in front of the filenames of the new files to differentiate between them.

The PHP code the software is using is:

{$convert_path}convert -units PixelsPerInch -density {$ppi} "{$path_i}{$file_i}" -resize {$w_size}x{$h_size} -quality {$quality} "{$path_o}{$file_o}"

Thanks for your help.

Re: Imagemagick and Stockboxphoto

Posted: 2012-05-10T10:08:28-07:00
by fmw42
try using mogrify in place of convert on the given directory and writing to a new directory is recommended so you don't overwrite the old files.

see
http://www.imagemagick.org/Usage/basics/#mogrify

My apologies, but I cannot make out what you are doing in your code. It looks like you are converting only one image at a time and that should work. If you are trying to convert 8 images and write to 8 new images with different names, I don't think you can do that with IM. You can convert 8 images, but then you have to write them to the same name. IM will then append -0,-1...-7 to the results or make one image with 8 frames depending upon the output file type.

In any case, if the 8 files are very big, then convert may run out of memory as it loads them all at one time.

Mogrify will process all images in a directory, but loads and processes them one at a time. So has better memory management. But you cannot rename the files. So you should write them to a different directory, unless you are converting all images from one format to a different format.

Please clarify what your code does.