Skip to content
This repository

"Bogus input colorspace" for "convert" command in map export #76

Closed
jywarren opened this Issue December 26, 2011 · 8 comments

1 participant

Jeffrey Warren
Jeffrey Warren
Owner

Lines 191 and on of https://github.com/jywarren/mapknitter/blob/master/app/models/warpable.rb typically generate something like:

convert -background transparent -contrast-stretch 0 /home/warren/sites/mapknitter.org/public/warps/ein-karem-working/3545-IMG_5407.JPG -crop 4716x4716+0+0! -background transparent -flatten -matte -virtual-pixel white +antialias -distort Perspective '0,0 0,3746 3648,0 1334,0 3648,2736 3901,1458 0,2736 2434,4716' -background transparent -flatten +repage /home/warren/sites/mapknitter.org/public/warps/ein-karem/3545.tif

Which is now throwing:

"convert: Bogus input colorspace. `JPEGLib' @ warning/tiff.c/TIFFErrors/493."

Adding -colorspace RGB in various locations doesn't seem to help.

http://www.imagemagick.org/script/command-line-options.php#colorspace

This is likely due to the upgrade from ImageMagick 6.5.x to 6.6.x when we upgraded the server to Ubuntu Server 11.10.

Crappy. Not making much progress. Help!

Jeffrey Warren
Owner

OK, "convert -background transparent -contrast-stretch 0 /home/warren/tmp/3545-IMG_5407.JPG -crop 4716x4716+0+0! /home/warren/tmp/3545.tif" works. that's eliminating all flags after the "crop" flag. But haven't been able to get it to run with any fewer reductions... perhaps the -flatten after the -crop flag is causing this?

Jeffrey Warren
Owner

convert tmp.jpg -crop 4716x4716+0+0! -flatten -distort Perspective '0,0 0,3746 3648,0 1334,0 3648,2736 3901,1458 0,2736 2434,4716' -flatten +repage tmp.tif

works, where

convert tmp.jpg -crop 4716x4716+0+0! -flatten -matte -distort Perspective '0,0 0,3746 3648,0 1334,0 3648,2736 3901,1458 0,2736 2434,4716' -flatten +repage tmp.tif

does not. So -matte, which is the equivalent of "-alpha Set", is probably causing the issue...

Jeffrey Warren
Owner

convert tmp.jpg -crop 4716x4716+0+0! -flatten -distort Perspective '0,0 0,3746 3648,0 1334,0 3648,2736 3901,1458 0,2736 2434,4716' -flatten +repage -geometry 300x tmp.tif

Attempting to make a separate mask:

convert -size 500x500 xc:black -draw "fill white stroke none polyline 0,3746 1334,0 3901,1458 2434,4716 " mask.gif

convert tmp.jpg -crop 4716x4716+0+0! -flatten -distort Perspective '0,0 0,3746 3648,0 1334,0 3648,2736 3901,1458 0,2736 2434,4716' -flatten +repage mask.gif -alpha Off -compose CopyOpacity -composite -geometry 300x tmp.tif

Jeffrey Warren
Owner

convert -size 4716x4716 xc:black -draw "fill white stroke none polyline 0,3746 1334,0 3901,1458 2434,4716 " mask.gif

then

convert tmp.jpg -crop 4716x4716+0+0! -flatten -distort Perspective '0,0 0,3746 3648,0 1334,0 3648,2736 3901,1458 0,2736 2434,4716' -flatten +repage tmp.tif

then

convert tmp.tif mask.gif -alpha Off -compose CopyOpacity -composite masked.tif

still yields

convert: Bogus input colorspace. `JPEGLib' @ warning/tiff.c/TIFFErrors/493.

damn!

Jeffrey Warren
Owner

OK using DstOut masking is making progress!!

convert tmp.jpg -crop 4716x4716+0+0! -flatten -distort Perspective '0,0 0,3746 3648,0 1334,0 3648,2736 3901,1458 0,2736 2434,4716' -flatten +repage tmp.tif

convert -size 4716x4716 xc:none -draw "fill black stroke none polyline 0,3746 1334,0 3901,1458 2434,4716 " mask.gif

convert tmp.tif mask.gif -compose DstIn -composite masked.tif

almost there... but somehow I can't produce an alpha layer, so the background remains black! Damn!

If I use -alpha Set or -matte, it throws the same "Bogus input colorspace" error!

Jeffrey Warren
Owner

http://www.imagemagick.org/Usage/compose/#copyopacity

convert tmp.jpg -crop 4716x4716+0+0! -flatten -distort Perspective '0,0 0,3746 3648,0 1334,0 3648,2736 3901,1458 0,2736 2434,4716' -flatten +repage tmp.tif

convert -size 4716x4716 xc:black -draw "fill white stroke none polyline 0,3746 1334,0 3901,1458 2434,4716 " mask.gif

convert tmp.tif mask.gif -alpha Off -compose Copy_Opacity -composite masked.tif

Still yields "convert: Bogus input colorspace. `JPEGLib' @ warning/tiff.c/TIFFErrors/493."

ug.

Jeffrey Warren
Owner

OK, have a version working with PNG output, which GDAL can read. Not ideal but functional, and now we can add edge blending soonish:

convert tmp.jpg -crop 4716x4716+0+0! -flatten -distort Perspective '0,0 0,3746 3648,0 1334,0 3648,2736 3901,1458 0,2736 2434,4716' -flatten +repage tmp.tif

convert -size 4716x4716 xc:none -draw "fill white stroke none polyline 0,3746 1334,0 3901,1458 2434,4716 " mask.png

composite mask.png tmp.tif -compose DstIn -alpha Set masked.png

Reintegrating into codebase...

Jeffrey Warren jywarren closed this in 03fa4b7 January 01, 2012
Jeffrey Warren
Owner

worked around it using .png instead of.tif, and a separate "composite" step to mask, as seen in the last comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.