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

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

Comments

Projects
None yet
1 participant
@jywarren
Owner

jywarren commented Dec 26, 2011

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!

@jywarren

This comment has been minimized.

Show comment
Hide comment
@jywarren

jywarren Dec 26, 2011

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?

Owner

jywarren commented Dec 26, 2011

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?

@jywarren

This comment has been minimized.

Show comment
Hide comment
@jywarren

jywarren Dec 27, 2011

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...

Owner

jywarren commented Dec 27, 2011

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...

@jywarren

This comment has been minimized.

Show comment
Hide comment
@jywarren

jywarren Dec 27, 2011

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

Owner

jywarren commented Dec 27, 2011

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

@jywarren

This comment has been minimized.

Show comment
Hide comment
@jywarren

jywarren Dec 27, 2011

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!

Owner

jywarren commented Dec 27, 2011

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!

@jywarren

This comment has been minimized.

Show comment
Hide comment
@jywarren

jywarren Dec 27, 2011

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!

Owner

jywarren commented Dec 27, 2011

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!

@jywarren

This comment has been minimized.

Show comment
Hide comment
@jywarren

jywarren Dec 28, 2011

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.

Owner

jywarren commented Dec 28, 2011

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.

@jywarren

This comment has been minimized.

Show comment
Hide comment
@jywarren

jywarren Dec 31, 2011

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...

Owner

jywarren commented Dec 31, 2011

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...

@jywarren jywarren closed this in 03fa4b7 Jan 1, 2012

@jywarren

This comment has been minimized.

Show comment
Hide comment
@jywarren

jywarren Jan 1, 2012

Owner

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

Owner

jywarren commented Jan 1, 2012

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