MODX Community

PhpThumb SVG to PNG conversion help

I’m trying to use pThumb (uses phpthumb) to convert an SVG to PNG, however the image has an outline and background baked into it. I have imagemagick on the server (2019 release), and not using resizer

Here is my call. I’ve tried removing AOE, no change there, I added DPI and gave it a crazy number just to see, no change.

   [[pthumb? &input=`[[++core-config-logo-svg]]` &options=`aoe=1&w=1200&h=1200&dpi=1200&f=png` &debug=`1`&toPlaceholder=`ogImageSVG`]]

Anyone have SVG to PNG conversions working?

So just to make sure I got your post right,
You are trying to convert an SVG to a PNG.
But it is having the undesired outcome of losing transparency and generating a background (e.g from isolated logo to a logo on a black background)?

If it is that, you may need to add an alpha/transparency option to your string. I had a similar issue when compressing PNG files it would automatically remove the transparency. I don’t have any links to any specific documentation though and this is all based off of memory. So take it for what it’s worth.

This is off the top of my head, but maybe try &bg=none

If not none maybe 0 or something else that indicates the alpha channel?

I don’t know about the outline though…

This is all dependent on how the svg is set up though. Does it have a background path?

In the end as I was trying to debug my SVG, I thought “You know, it’s faster just to export a few PNGs as part of my workflow” … I don’t like it, but it’s where I landed. I tried everything suggested with no real progress. I’m not sure phpthumb is the right tool for this job.

1 Like

I’ve had a similar problem related to SVG conversion, every time I got it converted, PNG looked weird. Got pretty similar issues with outlines and boundaries, which emerged where they shouldn’t. I even tried to change the values in my initial SVG files and still haven’t found any workable solution. Searched online for someone to help me and developers from this company somehow managed to solve the problem though I don’t know how.