Hi Ying,

Because JPG can't handle transparency, the alpha channel will be removed 
anyway by the conversion, so adding a line to remove it explicitly is 
unlikely to change anything. I'm not familiar with ImageMagick, but from a 
general graphics point of view, there are a couple of solutions:

(1) convert to PNG instead of JPG (since PNG can handle transparency)
(2) tell ImageMagick to use white as the background fill (or whatever your 
chosen colour is)

Since ImageMagickThumbnailFilter.java can only generate JPGs 
<https://github.com/DSpace/DSpace/blob/main/dspace-api/src/main/java/org/dspace/app/mediafilter/ImageMagickThumbnailFilter.java#L33>,
 
option (2) would be the way forward. From the ImageMagick docs 
<http://im4java.sourceforge.net/api/org/im4java/core/IMOps.html#background(java.lang.String)>,
 
my best first guess at how to do this would be something like:

replace
        if (flatten) {
            op.flatten();
        }
with
        if (flatten) {
            // set the background colour to white (could also try using, 
e.g. "white" or "rgb(255,255,255)")
            op.background("#ffffff")
            // flatten the image
            op.flatten();
        }

Hopefully others with better ImageMagick skills can correct any mistakes in 
my reasoning and/or syntax!

Best,
Ben


On Saturday, 12 September 2020 at 01:31:40 UTC+1 [email protected] wrote:

> Hi,
>
> We have some pdfs with transparent background. When using ImageMagick to 
> convert to jpg thumbnails, it has black background. I set 
> org.dspace.app.mediafilter.ImageMagickThumbnailFilter.flatten = true 
> in dspace.cfg, even add this line to ImageMagickThumbnailFilter.java in 
> getImageFile method.
>
> op.alpha("remove");
>
> Doesn't seem to work.
>
> We are on DSpace 6.3 and using ImageMagick 6.9.10-68, and GPL Ghostscript 
> 9.25 (2018-09-13) on redhat linux. 
>
> Is there anyone knows how to solve this problem?
>
> Thanks,
> Ying
>

-- 
All messages to this mailing list should adhere to the DuraSpace Code of 
Conduct: https://duraspace.org/about/policies/code-of-conduct/
--- 
You received this message because you are subscribed to the Google Groups 
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dspace-tech/5692389e-c3ec-4cec-8a60-3a17960ad0fbn%40googlegroups.com.

Reply via email to