how do you specify an AlphaChannelType arguments to alpha() in ruby imagemagick (magick)

StackOverflow https://stackoverflow.com/questions/21199124

  •  29-09-2022
  •  | 
  •  

سؤال

I'm trying to use the img.alpha(SOMETHING) command in the ruby magick library (in a custom manipulate routine used by carrierwave).

alpha() expects an argument of Magick::AlphaChannelType but I cannot find any doucmentaiton on how to specify such an argument, or what options are available.

The docs say the argument shoudl be:

One of the following values of the AlphaChannelType enumeration:

ActivateAlphaChannel Enable the images use of transparency. If transparency data did not exist, allocate the data and set to opaque. If the image previously had transparency data, the data is again enable as it was when turned off. The transparency data is not changed or modified in any way. ...

But do not give any examples of how to actually specify one of the 10 possible argument values.

هل كانت مفيدة؟

المحلول

The AlphaChannelTypes that alpha wants are constants within Magick so you want to use Magick::ActivateAlphaChannel, Magick::BackgroundAlphaChannel, ...:

img.alpha(Magick::ActivateAlphaChannel)

I don't my way around CarrierWave but I'd guess it just wants to see one of the Magick:: constants somewhere.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top