I am trying to convert a tiled multipage tiff into pdf using #itextpdf version 5.4.1. But itextPdf throws IllegalArgumentException while processing such tiffs. Do ItextPdf support conversion of tiled tiff? If not, what alternative way can be used for such conversion?
If you look at the details of that IllegalArgumentException you'll see that it's message is Tiles are not supported. Thus,
Do ItextPdf support conversion of tiled tiff?
No, iText does not support conversion of tiled tiff images to PDF images.
what alternative way can be used for such conversion?
Preprocess the image and transform it, either into a non-tiled tiff or into a different bitmap format altogether, before using it in iText.
Related
I'm generating JPEG image data using UIImageJPEGRepresentation(UIImage, 1.0) in Swift version 4(?).
I'm using a 3rd party JPEG decoder but it throws an error that no SOI (start of image) marker was found.
How do I generate a correctly formatted JPEG with SOI markers in Swift (preferably) or Objective-C?
Is this a known issue in standard Swift and should I start looking at 3rd party JPEG encoders?
Resolving under the assumption that the fault lies in the decoder and not UIImageJPEGRepresentation.
So I am using Dart's image package to manipulate an JPG image which was loaded and decoded.
Filtering the image works perfectly fine, however, display the image seems to be somewhat slow.
The idea was to use Flutter's Image widget in combination with a MemoryImage a la:
Image.memory(bytes)
bytes must be a binary representation of the image, e.g., PNG, JPG etc. and is not compatible with the image library's internal uint32 storage format or a simple bitmap. As a result, one is required to encode the bitmap back to a JPG which is pretty slow.
Is there a more efficient way of doing this?
I need to display the DICOM images in a browser. This requires, the DICOM to be converted to PNG (or any other compatible) format.
I also need to calculate some overlay pixels based on dynamic input from the user. On conversion to PNG, I am getting 4 values (Alpha, R, G, B). But I can not use these values for my calculations. I need the original HU values from the DICOM images.
Is there any way that, PNG can contain the original DICOM values. I heard that using monochromatic 16 bit PNG format it is possible. How do we do that?
Alternatively, how to load DICOM pixel data in browser preserving HU values?
When you convert DICOM pixel data to other non-DICOM format like PNG, BMP, JPG, J2K etc., the data you are looking for is lost. You may further research for TIF format whether it preserves the data and it loads in browser. I guess it will not.
I will recommend to avoid this way. Instead, I will suggest using DICOM pixel data as-is in browser. This can be achieved by involving some java-script DICOM toolkit for browsers like cornerstone. You may also look for other toolkit if available and suits you.
Note that this involves learning curve. It will be too broad here to explain its working.
I use imread function to read one jpeg file and save the rgb image in bmp format. Comparing the two files, I found artifacts appear and use green circle to denote artifacts. The version of OpenCV is 3.0. I compile the libraries by myself with SSE, SSE2 and SSE3 switchd on (default setting). My OS is windows 7 professional. You can use the following image to check.
original jpeg image
saved bmp file
If I read the jpeg file in Matlab, the rgb image is correct. I save rgb image in png format in Matlab, read the png file using opencv and save the loaded image in bmp file. Everything is OK. It seems that there is a problem with jpeg decoder. The jpeg library used is libjpeg.lib.
Due to the size limit, I cut the patch from the second image.
You're always going to get some artifacts in JPEG. You can reduce the appearance of such artifacts by changing the quantization tables used (usually with loss of compression).
JPEG encoders often use a "quality" setting to change the quantization tables.
I know how to create PDF from TIFFs. My question is:
How can itext just embed original TIFFs without modifying them?
I used document.add(img) (where img is the TIFF) to create a PDF. However, the TIFF was modified to smaller size. In this case, my original uncompressed b/w TIFF file size of 2.8 MB was compressed to CCITT Group 4 TIFFs.
Does itext have a way not to modify TIFF?
Please consult ISO-32000-1. If you read this standard closely, you'll find references to TIFF in the context of LZW and Flate filters, but you'll discover that TIFF is not one of the available filters in PDF. Table 6 shows the options:
As TIFF is not supported in PDF, iText has no other option than to convert it into a format that is accepted. In your case CCITTFaxDecode.
If you really want to keep the TIFF as-is, you need to add it as an attachment. That's explained in my answer to this question: Attaching files to a PDF