Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PNG vs JPG color off by 1
#3
(06-17-2021, 07:28 AM)Ofnuts Wrote: There could be a bug(*). But in practice, Gimp 2.10 doesn't work with integer values for color channels, all the processing is done in floating point,  and your [0..255] colors are converted to floating point after applying a gamma correction, which for some values can put them close to a tipping point for a round-off. The integer values are accepted in scripts for compatibility.

IMHO unless you are using a rare built-in Gimp filter there are more efficient ways to do you image processing. There are image processing libraries around (pillow, the Python binding for ImageMagick....). Also, the image processing core of Gimp is called GEGL and can be used independently of Gimp.


(*) feel free to report it here.

PS: gimpcolor.RGB(int(rgb[0]), int(rgb[1]), int(rgb[2])) ? gimpcolor.RGB(*map(int,rgb))!

Thank you for your reply, and for thinking beyond the scope of the original question.

1. Regarding the integer color values, that does not explain why the JPG output has the expected values but the PNG output does not. I need to get the PNG output to match the color values (like the JPG output).

2. Yes, I am aware of other processing tools we could use. The source PSD files from the design team have multiple groups, layers, and masks, and GIMP is a great tool for creating a composite for these in an unattended and automated environment without writing extra code. The existing PSD libraries for Python are not able to do this. Image Magick does not appear to have the features we need either. I am very familiar with pillow and magick and we use those (and even Blender) for image processing in other parts of our pipeline.

It sounds like you are very knowledgeable -- do you have any other ideas on how we might get the same output in the PNG to match an RGB input like we see when we export the composite to JPG?

Oh also I'll share how the composite is created and saved. Perhaps I should look at using file_jpeg_save (maybe quality 1.0 would work for me to avoid compression) or file_png_save (would any parameters help with this issue) instead?
Quote:file_jpeg_savenew_image = pdb.gimp_image_duplicate(image)
layer = pdb.gimp_image_merge_visible_layers(new_image, CLIP_TO_IMAGE)
pdb.gimp_file_save(new_image, layer, export_file, '?')
pdb.gimp_image_delete(new_image)
Reply


Messages In This Thread
PNG vs JPG color off by 1 - by af_luther - 06-16-2021, 11:08 PM
RE: PNG vs JPG color off by 1 - by Ofnuts - 06-17-2021, 07:28 AM
RE: PNG vs JPG color off by 1 - by af_luther - 06-17-2021, 04:17 PM
RE: PNG vs JPG color off by 1 - by Ofnuts - 06-17-2021, 07:32 PM
RE: PNG vs JPG color off by 1 - by af_luther - 06-17-2021, 07:52 PM
RE: PNG vs JPG color off by 1 - by Ofnuts - 06-17-2021, 07:59 PM
RE: PNG vs JPG color off by 1 - by af_luther - 06-17-2021, 08:59 PM
RE: PNG vs JPG color off by 1 - by Ofnuts - 06-18-2021, 12:19 AM

Forum Jump: