Why do ImageMagick-based thumbnail-images of PDF-files in Typo3 have black background? - pdf

Since version 6.7.5, ImageMagick has changed its colorspace from RGB to sRGB. Because of that I also had to change the setting [GFX][colorspace] = sRGB in the configuration of my Typo3 CMS software that makes use of ImageMagick. Everything is working fine again - except thumbnail-creation for PDF-files that now always have a black background (should be white).
It's possible to see all non-black elements of PDF-files (like images etc) on the thumbnails, but all the background that would usually be white is now black. This error only happens for PDF-files. All other image-thumbnails for JPG-, GIF- and PNG-files look as expected (even if they have transparent background).
Does anyone have an idea how I could solve this problem? Is this an ImageMagick-issue or a Typo3-Issue?

Based on Creating JPG thumbnails from PDF causes problems with new version of ImageMagick I was able to answer this question by myself. If your want to apply this solution to Typo3, the following file changes are needed:
Go to your Typo3 directory and open the file ./t3lib/class.t3lib_stdgraphic.php and replace all appearances of
$this->cmds['jpeg'] = '-colorspace ' . $this->colorspace . '
with
$this->cmds['jpeg'] = '-colorspace ' . $this->colorspace . ' -flatten

Use the ImageMagick convert with the "-flatten" option for the background. The actual "PDF" thumbnail conversion is passed to GhostScript as a delegate which means both must be installed on the server correctly. If done correctly which happens in most cases, the path for GhostScript within your coding is not needed if using ImageMagick. The actual PDF encoding can also be a problem. There are shared hosting accounts running 7 year old versions of both ImageMagick and GhostScript with no problem on PDF conversion to thumbnail within the current stable TYPO3 CMS 6.1.1.
A free direct download PDF test file with detailed instructions to solve a "PDF Thumbnail Generation Problem" in TYPO3 CMS is available at Smargasy, Inc. "http://www.smargasy.com/fileadmin/media_data/community/Smargasy_PDF-Thumbnail-Compatibility-Test-File.pdf". The test file helps isolate the problem on systems that use ImageMagick and GhostScript as the image processing and conversion program in a shared hosting environment.
Best Regards

Related

Is it possible to convert fabricjs svg output to pdf without rasterizing?

We are building a web app where the user can make a design by using fabric.js and at the end he should receive a pdf file with his work.
At first, we tried to use JSPDF because it was prefered to have a cliente-side solution. However by doing pdf.addImage(canvas.toDataURL(),...) we are rasterizing the design.
In second place, we tried server side solution using WKHTMLTOPDF, sending canvas.toSVG(), but there are some issues with fonts and shapes rendering.
The designs are complex as they can have text, shapes, images and svg.
We also tried INKSCAPE (inkscape --without-gui --export-pdf ...), MPDF and MUPDF without good results. IMAGEMAGICK is not a solution has it also rasterize the design.
The main goal is to get a vector pdf, where it's possible to increase size and where the elements of the design are selectable, and if possible that pdf should be ready to print (300 dpi and cmyk)
Yes its possible using TCPDF library.
Please check this ImageSVG api for more information for converting SVG to PDF.
https://tcpdf.org/examples/example_058/
Export the canvas to svg and use pdflib to make the pdf.
You can find an exemple here:https://www.pdflib.com/pdflib-cookbook/graphics/starter-svg/

phantomjs output file size: png v gif

With phantomjs you can choose the file format to use for page.render().
I'm finding that the file size I'm getting for png is around three times higher than what I'm getting for gif. I wasn't aware that png should be any worse (in terms of file size) than gif; in fact I thought png was meant to be better.
Unfortunately, I kinda need to output to png because of its support for variable opacity, but the larger file size is a bit of an issue.
So, is there any way in which I can control file size of the png? Maybe change the encoding scheme or something? I'm currently using phantomjs 1.9.8.
Inside of PhantomJS
No, there is no way to make the png file size smaller, but there is a way to make it bigger (just for fun):
Render the file to png,
load the file to a canvas of appropriate size,
get the Data-URI of the canvas in png or any other format,
decode the Base 64 part and write to file (this is very tricky to get right).
PhantomJS 1.x has a bug which results in a vastly inflated, but valid file.
Only jpeg rendering enables you to specify a quality setting which will result in a smaller file size, but then again jpeg doesn't support transparency.
You could also see whether PhantomJS 2.0.0 behaves better, because it has an engine underneath it that is almost three years newer than in PhantomJS 1.x.
Outside of PhantomJS
Your best bet would be to render the png in PhantomJS as-is and post-process it with your favorite library. It may even be enough to open it and save it again.
You can for example call an installed program with the child process module or your can open a webpage that contains such a service and upload the captured file or base64 representation of it. The possibilities are endless.

White image while inserting a SVG image in TCPDF

I'm trying to insert some SVG images in a PDF using TCPDF with the method TCPDF::ImageSVG, but when I try this I get a white space.
If I try to enable TCPDF::setRasterizeVectorImages the image shows in the PDF file, but it is rasterized of course and so its quality is not good.
Do you have any idea?
Thank you very much for your help!
Unfortunately, TCPDF's SVG handling is quite limited, and the cause of your issue depends on the SVG you are trying to use. Later versions of TCPDF support more SVG functionality, so if you haven't done so, try using a later version of TCPDF.
If an update doesn't resolve the issue, and you're forced to use raster images, you can improve quality at the cost of file size. You can do this by rasterizing them at a high DPI yourself outside of TCPDF. Once you've done this, take your new high-resolution raster image and add it to your PDF with the Image method like any other raster image. At work we usually rasterize to 300dpi, but your application may call for more or less.
If your image gets added to the PDF far larger on the page than you expected, specify at least one of the dimensions so TCPDF knows how much of the page you're intending the image to use.

ABCPdf 8.1 webpage to PDF image compression issue

I've just recently upgraded from ABCPdf 6 to ABCPdf 8.1.
I've got this webpage that I need to convert into PDF format.
The whole reason for the upgrade is because ABCPdf 6 cannot read Chinese characters while version 8.1 could.
I did a test of the page on the ABCPdf demo site (http://www.abcpdfeditor.com/) and things looks fine. (1.2Mb pdf)
However, when I tried to either:
run my own backend codeor run the code provided in the examples (C:\Program Files\WebSupergoo\ABCpdf .NET 8.1 x64\ExampleSite) - Identical to www.abcpdfeditor.com
All PDF generated produces really pixelated/compressed images! (121Kb)
The page that I'm trying to convert is:
http://debug.webpromos.com.au/certificate.htm
As far as I can tell, there is no issue with the code, but I've attached it below anyway...
http://debug.webpromos.com.au/html2pdf.ashx.txt
I'm stuck and can't think of anything else that could make it generate a 1.2Mb PDF document with non-pixelated image as produced by www.abcpdfeditor.com!
I hope I have provided enough information!
Thanks!
Wilfrid
Solved, all I need to do is to select the html engine specificly.
theDoc.HtmlOptions.Engine = EngineType.Gecko;

Webp very low quality when converting transparent PNG image files

I want to use Webp and get my images much small, at last for serving them to chrome browsers. I've download many types of conversion tools, including the official one. I tried to convert PNG with Alpha transparency and get awful results. See image below..
According to what I see on many websites, it shold handle transparency incredibly well. I wanted to know if you know why I get these kind of results and what I need to do or what tool I need to produce high quality webp transparent images that will replace my png ones.
Second, I wanted to know the comparability. Should I server those images only for chrome uses? - OF course the most important issue is the image quality outpu.
Thanks
You are probably using an older version of WebP library/binary, which didn't have alpha support. So the images you see have alpha channel stripped.
Try again with the latest release v0.2.0:
http://code.google.com/p/webp/downloads/list