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 two possible solutions:
(1) convert to PNG instead of JPG (since PNG can handle transparency) (2) get ImageMagick to use white as the background fill (or whatever your chosen colour is) It seems that ImageMagickThumbnailFilter.java <https://github.com/DSpace/DSpace/blob/main/dspace-api/src/main/java/org/dspace/app/mediafilter/ImageMagickThumbnailFilter.java> can only produce JPGs, so option (2) would seem to be the way forward. Looking at the ImageMagick docs <http://im4java.sourceforge.net/api/org/im4java/core/IMOps.html#background(java.lang.String)>, my best guess at how to do this would be to do something like: Replace: if (flatten) { op.flatten(); } with: if (flatten) { // First set the background colour: could also try using e.g. "white" or "rgb(255,255,255)" op.background("#ffffff") // Then flatten the image op.flatten(); } Hopefully others more familiar with ImageMagick can correct any mistakes in my reasoning and/or syntax! 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/dddbda5c-a73a-438a-ac7e-792e07de3209n%40googlegroups.com.
