PerlMagick colorspaceset

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
snibgo
Posts: 9380
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

PerlMagick colorspaceset

Post by snibgo » 2016-12-05T01:59:03-07:00

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.
snibgo's IM pages: im.snibgo.com

User avatar
magick
Site Admin
Posts: 10690
Joined: 2003-05-31T11:32:55-07:00

Re: PerlMagick colorspaceset

Post by magick » 2016-12-05T05:19:08-07:00

What about $im->Set(colorspace=>'sRGB')?

miket
Posts: 60
Joined: 2016-08-12T13:19:13-07:00
Authentication code: 1151

Re: PerlMagick colorspaceset

Post by miket » 2016-12-05T07:22:34-07:00

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

User avatar
magick
Site Admin
Posts: 10690
Joined: 2003-05-31T11:32:55-07:00

Re: PerlMagick colorspaceset

Post by magick » 2016-12-05T08:16:48-07:00

Got it. We'll add a patch in the next point release of PerlMagick within the next couple of weeks.

miket
Posts: 60
Joined: 2016-08-12T13:19:13-07:00
Authentication code: 1151

Re: PerlMagick colorspaceset

Post by miket » 2016-12-05T09:05:58-07:00

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

miket
Posts: 60
Joined: 2016-08-12T13:19:13-07:00
Authentication code: 1151

Re: PerlMagick colorspaceset

Post by miket » 2017-02-23T01:58:11-07:00

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

miket
Posts: 60
Joined: 2016-08-12T13:19:13-07:00
Authentication code: 1151

Re: PerlMagick colorspaceset

Post by miket » 2017-02-23T01:59:18-07:00

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

Post Reply