ImageMagick-6.7.5-7: validation failures on FreeBSD

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
agapon
Posts: 10
Joined: 2011-10-13T06:38:44-07:00
Authentication code: 8675308

ImageMagick-6.7.5-7: validation failures on FreeBSD

Post by agapon »

I get some ImageMagick validation failures on FreeBSD. The tests are validate-formats-in-memory and validate-formats-on-disk.
The failure messages are like the following:
test 858: EPI/Undefined/TrueColor/8-bits... fail (with distortion 3.78941e-06).
All tests for the following formats fail: EPI, EPS, EPSF, EPSI, EPT and PS. No other formats are affected.
I tried to look at what happens in GetMeanSquaredDistortion() and it seems that all the distortion comes from OpacityChannel.
(gdb) p distortion[OpacityChannel]
$17 = 0.99335677031755465
(gdb) p *(double[48]*)distortion
$18 = {0, 0, 0, 0, 0, 0, 0, 0, 0.99335677031755465, 0 <repeats 38 times>, 0.24833919257938866}
In all other channels the distortions are zero. The resulting CompositeChannels distortion is quite significant.

Does this ring any bells?
agapon
Posts: 10
Joined: 2011-10-13T06:38:44-07:00
Authentication code: 8675308

Re: ImageMagick-6.7.5-7: validation failures on FreeBSD

Post by agapon »

More data. It seems that the original image and the reconstructed image are the same with the bounded region, but outside it they have different opacity values.
As far as I can see the images have page size of 612x792, but the actual (bounded) image sizes are 70x46.
So, a pixel in the bounded area:
(gdb) p ((CacheInfo *)image->cache)->pixels[456552]
$38 = {blue = 11565, green = 12079, red = 12336, opacity = 0}
(gdb) p ((CacheInfo *)reconstruct_image->cache)->pixels[456552]
$37 = {blue = 11565, green = 12079, red = 12336, opacity = 0}
A pixel outside the bounded area:
(gdb) p ((CacheInfo *)image->cache)->pixels[400000]
$39 = {blue = 65535, green = 65535, red = 65535, opacity = 65535}
(gdb) p ((CacheInfo *)reconstruct_image->cache)->pixels[400000]
$40 = {blue = 65535, green = 65535, red = 65535, opacity = 0}
The opacity is 0 vs 65535.

Some additional debug data:
(gdb) p *image
$41 = {storage_class = DirectClass, colorspace = sRGBColorspace, compression = UndefinedCompression, quality = 0, orientation = UndefinedOrientation, taint = MagickFalse, matte = MagickTrue,
columns = 612, rows = 792, depth = 8, colors = 0, colormap = 0x0, background_color = {blue = 65535, green = 65535, red = 65535, opacity = 0}, border_color = {blue = 57311, green = 57311,
red = 57311, opacity = 0}, matte_color = {blue = 48573, green = 48573, red = 48573, opacity = 0}, gamma = 0.45455000000000001, chromaticity = {red_primary = {x = 0.64000000000000001,
y = 0.33000000000000002, z = 0}, green_primary = {x = 0.29999999999999999, y = 0.59999999999999998, z = 0}, blue_primary = {x = 0.14999999999999999, y = 0.059999999999999998, z = 0},
white_point = {x = 0.31269999999999998, y = 0.32900000000000001, z = 0}}, rendering_intent = PerceptualIntent, profiles = 0x805ff8e60, units = UndefinedResolution, montage = 0x0,
directory = 0x0, geometry = 0x0, offset = 0, x_resolution = 72, y_resolution = 72, page = {width = 612, height = 792, x = 0, y = 0}, extract_info = {width = 70, height = 46, x = 0, y = 0},
tile_info = {width = 0, height = 0, x = 0, y = 0}, bias = 0, blur = 1, fuzz = 0, filter = UndefinedFilter, interlace = NoInterlace, endian = UndefinedEndian, gravity = UndefinedGravity,
compose = OverCompositeOp, dispose = UnrecognizedDispose, clip_mask = 0x0, scene = 0, delay = 0, ticks_per_second = 100, iterations = 0, total_colors = 0, start_loop = 0, error = {
mean_error_per_pixel = 0, normalized_mean_error = 0, normalized_maximum_error = 0}, timer = {user = {start = 123.28125, stop = 0, total = 0}, elapsed = {start = 2547347.234375, stop = 0,
total = 0}, state = RunningTimerState, signature = 2880220587}, progress_monitor = 0, client_data = 0x0, cache = 0x8060cd000, attributes = 0x0, ascii85 = 0x0, blob = 0x804c6f800,
filename = "/var/tmp/magick-jzAGNRsI\000RsI\000\000\060\060\061", '\000' <repeats 4062 times>, magick_filename = "EPI:/var/tmp/magick-vmGuvYhC\000\060\060\060\061", '\000' <repeats 4062 times>,
magick = "EPI", '\000' <repeats 4092 times>, magick_columns = 612, magick_rows = 792, exception = {severity = UndefinedException, error_number = 0, reason = 0x0, description = 0x0,
exceptions = 0x806064a80, relinquish = MagickFalse, semaphore = 0x80e7fe580, signature = 2880220587}, debug = MagickFalse, reference_count = 1, semaphore = 0x80e7febc0, color_profile = {
name = 0x0, length = 2576, info = 0x8064b3000 "", signature = 0}, iptc_profile = {name = 0x0, length = 0, info = 0x0, signature = 0}, generic_profile = 0x0, generic_profiles = 0,
signature = 2880220587, previous = 0x0, list = 0x0, next = 0x0, interpolate = UndefinedInterpolatePixel, black_point_compensation = MagickFalse, transparent_color = {blue = 0, green = 0, red = 0,
opacity = 65535}, mask = 0x0, tile_offset = {width = 0, height = 0, x = 0, y = 0}, properties = 0x805ff8ec0, artifacts = 0x0, type = UndefinedType, dither = MagickTrue, extent = 3014656,
ping = MagickFalse, channels = 0}
(gdb) p *reconstruct_image
$42 = {storage_class = DirectClass, colorspace = sRGBColorspace, compression = UndefinedCompression, quality = 0, orientation = UndefinedOrientation, taint = MagickFalse, matte = MagickTrue,
columns = 612, rows = 792, depth = 8, colors = 0, colormap = 0x0, background_color = {blue = 65535, green = 65535, red = 65535, opacity = 0}, border_color = {blue = 57311, green = 57311,
red = 57311, opacity = 0}, matte_color = {blue = 48573, green = 48573, red = 48573, opacity = 0}, gamma = 0.45455000000000001, chromaticity = {red_primary = {x = 0.64000000000000001,
y = 0.33000000000000002, z = 0}, green_primary = {x = 0.29999999999999999, y = 0.59999999999999998, z = 0}, blue_primary = {x = 0.14999999999999999, y = 0.059999999999999998, z = 0},
white_point = {x = 0.31269999999999998, y = 0.32900000000000001, z = 0}}, rendering_intent = PerceptualIntent, profiles = 0x805ff8da0, units = UndefinedResolution, montage = 0x0,
directory = 0x0, geometry = 0x0, offset = 0, x_resolution = 72, y_resolution = 72, page = {width = 612, height = 792, x = 0, y = 0}, extract_info = {width = 70, height = 46, x = 0, y = 0},
tile_info = {width = 0, height = 0, x = 0, y = 0}, bias = 0, blur = 1, fuzz = 0, filter = UndefinedFilter, interlace = NoInterlace, endian = UndefinedEndian, gravity = UndefinedGravity,
compose = OverCompositeOp, dispose = UnrecognizedDispose, clip_mask = 0x0, scene = 0, delay = 0, ticks_per_second = 100, iterations = 0, total_colors = 0, start_loop = 0, error = {
mean_error_per_pixel = 0, normalized_mean_error = 0, normalized_maximum_error = 0}, timer = {user = {start = 123.7421875, stop = 0, total = 0}, elapsed = {start = 2547348.3359375, stop = 0,
total = 0}, state = RunningTimerState, signature = 2880220587}, progress_monitor = 0, client_data = 0x0, cache = 0x8060ca800, attributes = 0x0, ascii85 = 0x0, blob = 0x804c6f500,
filename = "/var/tmp/magick-CMqGZld1\000%08d\000\060\060\061", '\000' <repeats 4062 times>, magick_filename = "EPI:/var/tmp/magick-CMqGZld1\000\060\060\060\061", '\000' <repeats 4062 times>,
magick = "PNG", '\000' <repeats 4092 times>, magick_columns = 612, magick_rows = 792, exception = {severity = UndefinedException, error_number = 0, reason = 0x0, description = 0x0,
exceptions = 0x806064a40, relinquish = MagickFalse, semaphore = 0x80e7fe9c0, signature = 2880220587}, debug = MagickFalse, reference_count = 1, semaphore = 0x80e7fe480, color_profile = {
name = 0x0, length = 2576, info = 0x8064b5000 "", signature = 0}, iptc_profile = {name = 0x0, length = 0, info = 0x0, signature = 0}, generic_profile = 0x0, generic_profiles = 0,
signature = 2880220587, previous = 0x0, list = 0x0, next = 0x0, interpolate = UndefinedInterpolatePixel, black_point_compensation = MagickFalse, transparent_color = {blue = 0, green = 0, red = 0,
opacity = 65535}, mask = 0x0, tile_offset = {width = 0, height = 0, x = 0, y = 0}, properties = 0x805ff8f80, artifacts = 0x0, type = UndefinedType, dither = MagickTrue, extent = 15536,
ping = MagickFalse, channels = 0}
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick-6.7.5-7: validation failures on FreeBSD

Post by magick »

We'll need to investigate. It looks like the problem may be a conversion from the RGB to sRGB colorspace or visa-versa. We'll need time to confirm.
agapon
Posts: 10
Joined: 2011-10-13T06:38:44-07:00
Authentication code: 8675308

Re: ImageMagick-6.7.5-7: validation failures on FreeBSD

Post by agapon »

Just noticed that in reconstruct_image:
magick = "PNG"
Is this correct? Is this of any significance?
agapon
Posts: 10
Joined: 2011-10-13T06:38:44-07:00
Authentication code: 8675308

Re: ImageMagick-6.7.5-7: validation failures on FreeBSD

Post by agapon »

This is what I don't understand. It seems that when post script image of size x*y gets rendered via ghostscript, it get rendered into an (aplha)png image with actual size X*Y (media size) that contains the original x*y image plus a transparent filler. If that png image is rendered as a postscript file again the transparent area gets represented using "FF" (in WritePSImage) and the image size is still X*Y. If the resulting postscript file is rendered to alpha(png) yet again, those "FF" pixels seem to get translated to white pixels and all transparency information is lost.
So either ImageMagick's PS code incorrectly encodes transparency information or ghostscript incorrectly interprets it. Or something else... Maybe the original size x*y should have played a role.
agapon
Posts: 10
Joined: 2011-10-13T06:38:44-07:00
Authentication code: 8675308

Re: ImageMagick-6.7.5-7: validation failures on FreeBSD

Post by agapon »

BTW, the ghostscript documentation says this:
The pngalpha device is 32-bit RGBA color with transparency indicating pixel coverage. The background is transparent unless it has been explicitly filled.
I am not sure if ImageMagick generates a correct postscript that leaves those pixels unfilled.
agapon
Posts: 10
Joined: 2011-10-13T06:38:44-07:00
Authentication code: 8675308

Re: ImageMagick-6.7.5-7: validation failures on FreeBSD

Post by agapon »

Not sure what magic you did but the issue is resolved in the ImageMagick 6.7.5-10.
Thank you!
Post Reply