Process modules and palettes
Posted: 2014-09-11T12:01:56-07:00
(I think this is a bug, but maybe it's a development issue.)
I have written a number of "-process" modules. See my page http://im.snibgo.com/customim.htm .
Fred has discovered, and I confirm, that they don't work correctly when the input (and hence the output) is a palette image.
I have built these with IM 6.8.9-6 Q32 HDRI. I don't know what Fred has used.
For example, replacelast.c (at http://im.snibgo.com/customim.htm#replacelast.c ) is a trivial module that replaces the image with one of the same size, but green.
This result is correct:
![Image](https://dl-web.dropbox.com/get/roseRL1.png?_subject_uid=139892001&w=AAAQNC_8m3ap6Ytsa-ii5HOq1ZPIPPNDRrogUnskT1wvGA&dl=1)
![Image](https://dl-web.dropbox.com/get/roseRL.gif?_subject_uid=139892001&w=AABPaFZjbYy6DgGdCJlFJVhOS3CuMDdYNqAMmtNm7JO6ig&dl=1)
This result is incorrect. Every pixel is nearly black, (43,47,30) out of 255:
![Image](https://dl-web.dropbox.com/get/roseRL2.png?_subject_uid=139892001&w=AADxXrse5-POJLBjsmdvBXgz6mAyHrlNfC73fFkC6fwHPg&dl=1)
The problem also occurs in other modules, where I use SetPixelRed() etc, with QuantumRange values. The common factor in the problem is a palette input file. A workaround is "-type truecolor" to prevent the output from being palette.
If I should be doing something else in my code to prevent the problem, I'm happy to do it. But I hope my code doesn't need to worry about whether the image is palette.
I have written a number of "-process" modules. See my page http://im.snibgo.com/customim.htm .
Fred has discovered, and I confirm, that they don't work correctly when the input (and hence the output) is a palette image.
I have built these with IM 6.8.9-6 Q32 HDRI. I don't know what Fred has used.
For example, replacelast.c (at http://im.snibgo.com/customim.htm#replacelast.c ) is a trivial module that replaces the image with one of the same size, but green.
Code: Select all
%IMDEV%convert rose: -process replacelast roseRL1.png
![Image](https://dl-web.dropbox.com/get/roseRL1.png?_subject_uid=139892001&w=AAAQNC_8m3ap6Ytsa-ii5HOq1ZPIPPNDRrogUnskT1wvGA&dl=1)
Code: Select all
%IMDEV%convert rose: roseRL.gif
![Image](https://dl-web.dropbox.com/get/roseRL.gif?_subject_uid=139892001&w=AABPaFZjbYy6DgGdCJlFJVhOS3CuMDdYNqAMmtNm7JO6ig&dl=1)
Code: Select all
%IMDEV%convert roseRL.gif -process replacelast roseRL2.png
![Image](https://dl-web.dropbox.com/get/roseRL2.png?_subject_uid=139892001&w=AADxXrse5-POJLBjsmdvBXgz6mAyHrlNfC73fFkC6fwHPg&dl=1)
The problem also occurs in other modules, where I use SetPixelRed() etc, with QuantumRange values. The common factor in the problem is a palette input file. A workaround is "-type truecolor" to prevent the output from being palette.
If I should be doing something else in my code to prevent the problem, I'm happy to do it. But I hope my code doesn't need to worry about whether the image is palette.