GIF -> JPG transparency conversion is unconfigurable

Archived from the Transloadit support forum. Originally posted on September 13, 2011; details may be outdated, see our docs for current behavior. Original thread

When resizing a GIF with transparency to JPG, transparent areas are converted to black. This is expected behavior according to http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=8359, assuming the same applies to GIF (the url talks about PNG).

The link to that was provided by Tim Koschuetzki, who also points out that setting the background to “#FFFFFF” should be a fix at http://transloadit.com/docs/image-resize.

My configuration is:

{
  "steps": {
    "resize": {
      "robot": "/image/resize",
      "width": 750,
      "height": 195,
      "format": "jpg",
      "background": "#FFFFFF"
    },
    ...

Figured this might warrant its own ticket. It’s unclear whether it’s a bug or feature request, but probably more than should be handled by the documentation comments : )

Hi woody,

sorry currently you cant do this because you need to flatten all layers.
We definitely have this on our todo-list.

Kind regards,
Tim

I have the same problem here. It’s annoying when users try to upload transparent gifs and those result in mostly black images. I tested also with png and it seemed to work. I dunno if the png had different bg-colors or something.

With imagemagic I have used one of the following

“strip -bordercolor White -border 0” OR
“-strip -background White -flatten”

Approaches were described in Woody’s link.

Can’t you just enable flattening or border and border-color commands to imagemagick? Would be easy to have in specific steps “border”: 1x1 and “bordercolor”: White.

Hi olli,

now we automatically flatten all layers.

Kind regards,
Karl Skomski

Cool, thanks \o/