Page 1 of 1
(again:) Magick++: how to "-sampling-factor XxY"
Posted: 2012-09-17T04:42:21-07:00
by jbarth_ubhd
Dear Forum,
why does this not work?:
im.read(width, height, "RGB", CharPixel, im_rgb);
im.magick("JPEG");
im.quality(75);
im.defineValue("JPEG", "sampling-factor", "1x1,1x1,1x1");
im.write(varMap["of"].as<string>());
J. Barth
Re: (again:) Magick++: how to "-sampling-factor XxY"
Posted: 2012-09-17T13:19:38-07:00
by glennrp
jbarth_ubhd wrote:Dear Forum,
why does this not work?:
im.read(width, height, "RGB", CharPixel, im_rgb);
im.magick("JPEG");
im.quality(75);
im.defineValue("JPEG", "sampling-factor", "1x1,1x1,1x1");
im.write(varMap["of"].as<string>());
J. Barth
There seems to be a bug in coders/jpeg.c. At line 2300
Code: Select all
value=GetImageProperty(image,"jpeg:sampling-factor");
should probably be
Code: Select all
value=GetImageOption(image_info,"jpeg:sampling-factor");
if (value == (char *) NULL)
value=GetImageProperty(image,"jpeg:sampling-factor");
We have to check both Options and Properties so we handle
commandline input and also image data inherited from the
input image. With this change it works from the commandline
Code: Select all
convert logo: -define jpeg:sampling-factor="1x1,1x1,1x1" logo.jpg
convert logo.jpg logo2.jpg
logo.jpg and logo2.jpg both have the desired sampling-factors.
I assume that "im.defineValue" works the same as "-define" on the commandline.
Re: (again:) Magick++: how to "-sampling-factor XxY"
Posted: 2012-09-23T19:35:24-07:00
by anthony
glennrp wrote:
We have to check both Options and Properties so we handle
commandline input and also image data inherited from the
input image. With this change it works from the commandline
Code: Select all
convert logo: -define jpeg:sampling-factor="1x1,1x1,1x1" logo.jpg
convert logo.jpg logo2.jpg
logo.jpg and logo2.jpg both have the desired sampling-factors.
I assume that "im.defineValue" works the same as "-define" on the commandline.
-define sets an artifact, which is what is looked up by various coders and operators as needed.
in IMv7 the properity (or escape) lookup will look for "attributes" (non-string per-image values, like width), "properties" (saved image meta-data), "artefacts" (non-saved per-image settings), and options (global user settings). In IMv6 "options" are coped (repeatly) into "artefacts", IMv7 have a link to it.
Note: Artefact lookup IMv7 also does a global "option" lookup, following the link back to the containing "wand" that holds image sequences.
Many API's do not have a 'wand' of global "options", so you need to set artifacts, on every image directly.