Page 1 of 1

GIF resizing issue

Posted: 2009-01-26T12:33:03-07:00
by Deepstar
Hi,

I have a problem with the "convert -resize" function concerning GIF-files.
Background info: I operate a small Wiki (based on MediaWiki). After uploading GIF-files are automatically scaled down to thumbnails for the articles by MediaWiki using ImageMagick. But the conversion is terminated with the error message "Error during creation of preview image: segmentation fault" ("Fehler beim Erstellen des Vorschaubildes: Segmentation fault")

When I launch ImageMagick on the command prompt e.g. with "convert -resize 100x100 test.gif output.gif" I always get "Segmentation fault: 11". I have tested several GIF-files with different source and target sizes but always got the same error. Resizing of other file formats (JPG, PNG) works fine (on command prompt and via WikiMedia).

My hoster has installed ImageMagick 6.4.3 2008-09-01 Q16
The OS is FreeBSD 6.2-RELEASE-p3 #3: Tue Mar 27 15:43:45 CEST 2007

Any idea what's going wrong?

Thanks in advance!

Best regards
Deepstar

Re: GIF resizing issue

Posted: 2009-01-26T12:40:32-07:00
by magick
To fix a problem we need to reproduce it. Can you post a URL to an example GIF image that fails or does it fail for all GIF images? If so let's find out if its in input or output. If this command fails:
  • convert -resize 100x100 test.gif output.gif
Does this one:
  • convert -resize 100x100 test.gif output.jpg

Or this one:
  • convert logo: -resize 100x100 output.gif
We have not heard of this problem before, we're a bit perplexed why ImageMagick is failing for you.

Re: GIF resizing issue

Posted: 2009-01-26T13:06:35-07:00
by Deepstar
Hi,
thanks for your quick response! :D
magick wrote:To fix a problem we need to reproduce it. Can you post a URL to an example GIF image that fails or does it fail for all GIF images?
It fails for all GIF images I've tested (GIF87a and GIF89a), so I assume it's a general problem of GIF images.
magick wrote:If so let's find out if its in input or output. If this command fails:
  • convert -resize 100x100 test.gif output.gif
Segmentation fault: 11, as mentioned above.
magick wrote:Does this one:
  • convert -resize 100x100 test.gif output.jpg
Works!
magick wrote:Or this one:
  • convert logo: -resize 100x100 output.gif
Segmentation fault: 11
When the segmentation fault occurs, two empty files are created: convert.core and output.gif (with a size of 0 bytes).
magick wrote:We have not heard of this problem before we're a bit perplexed why ImageMagick is failing for you.
I was quite surprised as well that this error has not been reported in the past. :wink:

Best regards
Deepstar

Re: GIF resizing issue

Posted: 2009-01-26T13:09:02-07:00
by magick
The problem occurs when writing a GIF image. Now lets see if its strictly GIF or the color reduction algorithm. Type
  • convert -resize 100x100 test.gif -colors 256 output.png
Does this fail?

Re: GIF resizing issue

Posted: 2009-01-26T13:11:50-07:00
by Deepstar
magick wrote:The problem occurs when writing a GIF image. Now lets see if its strictly GIF or the color reduction algorithm. Type
  • convert -resize 100x100 test.gif -colors 256 output.png
Does this fail?
Yes, with a new error message: "convert: Memory allocation failed `test.gif'."

Re: GIF resizing issue

Posted: 2009-01-26T13:43:04-07:00
by magick
Your host must limit your memory or stack such that ImageMagick cannot do its work when reducing colors. Anyway to increase your memory and see if that fixes the problem?

Re: GIF resizing issue

Posted: 2009-01-26T15:55:50-07:00
by Deepstar
Hi,
thanks for your support!
magick wrote:Your host must limit your memory or stack such that ImageMagick cannot do its work when reducing colors. Anyway to increase your memory and see if that fixes the problem?
I have some questions to your reply:
- Why has ImageMagick to reduce the color depth? I want to resize a 256 color GIF, which of course already has the right number of colors. Does the algorithm increase the color depth to e.g. 16M, then resize and after this reduce again to 256?
- Why does the conversion of other file formats works fine? Is the color reduction algorithm so memory consumptive? Even a 15 MB large PNG (3000x3600 pixel) can be successfully resized to 200x200 pixels on the server but a 3 kb large GIF (500x500 pixel) can not?
- A stupid question :oops: : How can I figure out the memory and stack size of the server where my webspace is located? (I'm not so familiar with these things.)
"free" does not work (not found or no permission).
"vmstat -a" gives

Code: Select all

procs      memory      page                    disks     faults      cpu
 r b w     avm    fre  flt  re  pi  po  fr  sr da0 pa0   in   sy  cs us sy id
 0 1 0 3442956 228272  187   8   3   0 202 198   0   0  708  744 100 13 10 76
but I'm not sure how to interpret these data.

In the past ImageMagick was able to successfully resize GIF images on the server. There are many examples of GIF thumbnails in the Wiki. But then the errors occured. I don't know if this was associated with an update of ImageMagic by the provider or with something else. I don't think the provider has changed the available memory per user.

BTW: I see no realistic chance that the provider will increase the memory for me. But it doesn't cost anything to ask. :wink:

Best regards
Deepstar

Re: GIF resizing issue

Posted: 2009-01-26T17:23:31-07:00
by magick
Next up, try this:
  • convert -resize 100x100 test.gif +dither -colors 256 output.png
Does that work? Can you try ImageMagick 6.4.8-9, the current release, and see if that fixes the problem?

Re: GIF resizing issue

Posted: 2009-01-27T13:07:04-07:00
by Deepstar
Hi,
magick wrote:Next up, try this:
  • convert -resize 100x100 test.gif +dither -colors 256 output.png
Does that work?
Yes it works!
magick wrote: Can you try ImageMagick 6.4.8-9, the current release, and see if that fixes the problem?
I doubt that this will work.
I downloaded the source version for Unix. After unpacking I started "./configure" but I always got "./configure: fork: Resource temporarily unavailable". After 16 messages of this type the process terminated with "configure: error: cannot run /usr/local/bin/bash config/config.sub". I tried it several times but always with the same result.
I also downloaded the binary version "ImageMagick-i386-unknown-freebsd6.2.tar.gz" for FreeBSD 6.2. It contains ImageMagick 6.3.7 (Why not a newer version?). After unpacking, setting the the environment variable and the path convert is still launched from the path the hoster has set. When I start it with an absolute path to the newly installed Version on ImageMagick 6.3.7 convert is missing a lib (/libexec/ld-elf.so.1: Shared object "libMagick.so.10" not found, required by "convert").

Best regards
Deepstar

Re: GIF resizing issue

Posted: 2009-01-27T13:25:05-07:00
by magick
If a compile fails you are clearly resource constrained. You need more memory or stack to ensure ImageMagick completes without complaint.

Re: GIF resizing issue

Posted: 2009-01-27T15:38:27-07:00
by Deepstar
How much memory and stack does ImageMagic need at least?

Re: GIF resizing issue

Posted: 2009-01-27T17:33:16-07:00
by magick
Memory requirements are variable depending on your workflow. ImageMagick does recognize memory constrained systems and diverts image pixels from memory to disk. However, some algorithms require heap memory and if its not available, it fails. Color reduction is one such algorithm that is memory intensive. We added a patch to the GIF coder so that if color reduction fails, it exits with an exception message.

The first thing you should check is your shell limits. Type
  • limit
and see if it returns reasonable values. Also check to see how much memory your system has. Now-a-days many computers have 2GB of memory or more.

Re: GIF resizing issue

Posted: 2009-01-28T14:07:15-07:00
by Deepstar
Hi,
thanks for your ongoing support!
Just to clarify: My Wiki is not running on my own (physical) server, I share the server with several (many?) other customers of the hoster (GoNeo, a German hoster). I have no root rights, to many functions/programs I have no access or permission (so it's a shared server not a dedicated). I don't know any details about the hardware used by the hoster.
And I'm not an unix expert, but I try to do my best to provide the information you need to support me. :wink:
"limit" is not a known command so I tried "limits":
# limits
Resource limits (current):
  • cputime 10 secs
    filesize infinity kB
    datasize 524288 kB
    stacksize 65536 kB
    coredumpsize 1024 kB
    memoryuse 76800 kB
    memorylocked infinity kB
    maxprocesses 5
    openfiles 11095
    sbsize infinity bytes
    vmemoryuse 76800 kB

Re: GIF resizing issue

Posted: 2009-01-28T14:20:39-07:00
by magick
These questions are about Linux support rather than ImageMagick. You will need to go to one of the Linux user groups for additional help or talk with your ISP about increasing your memory restrictions (see memoryuse).

Re: GIF resizing issue

Posted: 2009-01-28T14:31:11-07:00
by Deepstar
I will try this. Thanks!