Page 1 of 1

PerlMagick colorspaceset

Posted: 2016-12-05T01:59:03-07:00
by snibgo
See thread viewtopic.php?f=7&t=30980
User miket has discovered that PerlMagick has no option to set a colorspace, so he added one for his own installation, naming the new option "colorspaceset".

I suggest this is added as a permanent standard feature to PerlMagick.

Re: PerlMagick colorspaceset

Posted: 2016-12-05T05:19:08-07:00
by magick
What about $im->Set(colorspace=>'sRGB')?

Re: PerlMagick colorspaceset

Posted: 2016-12-05T07:22:34-07:00
by miket
I'm looking to set the colorspace to XYZ without any transformation (similar to command line -set colorspace XYZ). The perl implementation assumes sRGB colorspace and applies a transformation (similar to -colorspace XYZ). See original post for more detail.

I tried $im->Set(colorspace=>'XYZColorspace'), but that throws an "unrecognised colorspace" error.

If you could formally implement this, I'd be grateful. I have no hangups about the naming used (colorspaceset just seemed convenient to me at the time !). I'm also no expert in perl/IM, so please do check the approach I've taken !!

Mike

Re: PerlMagick colorspaceset

Posted: 2016-12-05T08:16:48-07:00
by magick
Got it. We'll add a patch in the next point release of PerlMagick within the next couple of weeks.

Re: PerlMagick colorspaceset

Posted: 2016-12-05T09:05:58-07:00
by miket
Thanks Magic, Looking forward to it.

I've been testing my home-brew function this afternoon, and it appears to work reliably.

In terms of naming the function:

Option 1
Starting with a blank piece of paper you would use $im->Colorspace(colorspace=>'XYZ') to mimic -colorspace XYZ
and $im->Set(colorspace=>'XYZ' ) to mimic -set colorspace XYZ.
However, that would involve altering the functionality of a long standing command (unlikely to be popular).

Option 2
Retain $im->Set(colorspace=>"XYZ") for -colorspace XYZ
add new function $im_>Set(Set_colorspace=>"XYZ) or $im->Set(Colorspace_set=>"XYZ") for -set colorspace XYZ.
Easy to program and 1st version has the words in the correct order (similar to command line)

Option 3
Prefix or suffix the colorspace attribute (which is what you may have been getting at in your initial post)
$im->Set(colorspace=>"set_XYZ") or $im->Set(colorspace=>"XYZ_set").
Marginally more tricky to programme, and perhaps not quite so clear.

Personally I'd prefer something along the lines of Option 2, but you guys know your stuff so I'll leave that to you.

Thanks again for your assistance.

........... and (now I've got a few months experience under my belt) IM is a fantastic product - though not without it's foibles :).

Mike

Re: PerlMagick colorspaceset

Posted: 2017-02-23T01:58:11-07:00
by miket
Hi,

Thanks for this upgrade! It is now working perfectly for me.

For those following this post the ->Set(colorspace=>"-------") now no longer converts the file to the new colorspace, but only sets the colorspace flag.

The new command ->Colorspace(colorspace=>"-----") is the one to use for converting from one colorspace to another.

Mike

Re: PerlMagick colorspaceset

Posted: 2017-02-23T01:59:18-07:00
by miket
Just an observation: When applying ->Set(colorspace=>"XYZ") to an RGB file (or ->Colorspace(colorspace=>"XYZ") or using "xyY") and THEN applying ->Set(alpha=>"On") an extra 4th channel (in addition to the XYZ & Alpha channels) appears to be generated and identified by Identify. Is this behavior expected? It doesn't appear (so far) to affect downstream processing.

Mike