Ubuntu – ImageMagick convert and low RAM

14.04amazon ec2image processingimagemagick

Please consider the following command for the imagemagick package:

sudo convert -resize 460x200 /path/to/test1.jpg /path/to/test2.jpg

Now test1.jpg is a fairly large image (12.5MB), but not unheard of sizes, but the server I am working from only has 1G of memory (Amazon EC2 t2.micro if it helps)

No error is being thrown, and yet no test2.jpg is being created. I have tested this with smaller images and it works fine. I would have thought 1G if memory would be plenty to manage a resize, but perhaps not?

What are my options, do I have to get more memory or am I missing something?

Any suggestions are very welcome!

Requested Edits

strace output shows: +++ killed by SIGKILL +++ along with alot of commands that look normal (opening /usr/share/local and reading long strings, which I assume is image data)

free gives me:

         total       used       free     shared    buffers     cached
Mem:       1016292     278348     737944       6412        460      13356
-/+ buffers/cache:     264532     751760
Swap:            0          0          0

So it looks as if swap is not enabled, so I will look into creating a swapfile to see if this sorts my issues.

File gives me:

testprint10Mbv2.jpg: JPEG image data, EXIF standard

I would also paste the full /path/to/img but unfortunately it contains sensitive data (client email addresses etc)

Best Answer

I'm assuming you are running out of RAM. You can verify this with watch cat /proc/meminfo while your process is running.

You may have insufficient RAM and/or SWAP to accomplish your task.

Due to the low-ram condition, insure that swap is on with swapon -a and if no swap is setup on the system create a partition for swap on unused diskspace and enable it. This will likely solve the problem. There's a good answer by @Takkat on how to do that here If you don't have access to partitioning the server you can also use a swapfile for swap