When I convert a Multi-Image TIF File to Individual TIF Files using ImageMagick I'm getting a Warning stating "Invalid TIFF Directory; tags are not sorted in ascending order'.
convert.exe: Invalid TIFF directory; tags are not sorted in ascending order.
'TIFFReadDirectoryCheckorder' # warning/tiff.c/TIFFWarnings/847
Hoping for Any advice I can get on this error. I am trying to take a Multi-Image TIF File and Turn it into Individual Files, however I need them to be in the order in which they were listed in the Original TIF File for this to work.
If you still have the issue check the limitation disk:
convert -list resource
Example for debian 9 /etc/ImageMagick-6/policy.xml.
I hope that could be helpful.
Related
I have found multiple posts regarding this issue and everyone is recommending ImageMagick but for me, it doesn't seem to work as intended and I don't see too many docs on their site regarding .jpg->.pdf conversion.
Is there some alternative, preferably CLI tool?
Or can I somehow debug why ImageMagick doesn't work for me? I don't get any errors I just get corrupted files as a result.
My usecase
My os is Windows and
I have 64 .jpg files called 0.jpg, 2.jpg, ... 63.jpg and I would like to merge all those images into one .pdf file.
I have tried these commands:
magick *.jpg out.pdf
convert *.jpg out.pdf
but in both cases, I am unable to open the out.pdf file because it is corrupted. I have noticed that I can only convert 0.jpg file to pdf correctly but when I try to convert any other of my 64 jpg files then as a result I am getting a corrupted .pdf file
For example:
This gives me the correct .pdf:
magick 0.jpg 0.pdf
but this gives me corrupted .pdf:
magick 2.jpg 2.pdf
I assume that this a reason why I can't merge all of the files into one not corrupted .pdf file and my assumption is that there is something wrong with the rest of my .jpg files but I have no idea how to debug this issue. Every other .jpg file looks exactly the same as the one .jpg I can convert and all of them open without issues.
magick identify -verbose foobar.jpg results:
I can convert 0.jpg file to .pdf correctly but 2.jpg results in corrupted .pdf.
There are some apparent differences but I am not sure what those properties mean in the context of .jpg -> .pdf conversion
One thought is that someone has converted the grayscale image to color with 3 equal channels so that it IM says it has colorspace RGB. However, the JPEG colorspace tag is 2, which says it has no specific colorspace.
Properties:
date:create: 2021-04-01T17:29:06+00:00
date:modify: 2021-04-01T05:18:58+00:00
exif:ExifOffset: 46
exif:ExifVersion: 48, 50, 50, 48
exif:PixelXDimension: 960
exif:PixelYDimension: 1508
exif:Software: Google
jpeg:colorspace: 2
jpeg:sampling-factor: 2x2,1x1,1x1
From the JPG docs
ColorSpace
0 = Bi-level
1 = YCbCr, ITU-R BT 709, video
2 = No color space specified
3 = YCbCr, ITU-R BT 601-1, RGB
4 = YCbCr, ITU-R BT 601-1, video
8 = Gray-scale
9 = PhotoYCC
10 = RGB
11 = CMY
12 = CMYK
13 = YCCK
14 = CIELab
It is possible that this conflict or lack of colorspace may confuse certain viewers after the file is imbedded in a PDF vector shell.
Thank you #Mark Setchell for pointing me in the right direction by sharing this command:
magick identify -verbose XXX.jpg
My images are grayish so I don't know why majority of the files has sRGB colorspace but after converting colorspace to Gray I can convert them to .pdf properly (I don't see any difference when I open up my .jpgs after conversion to grayscale).
Using this command I can change colorspace to Gray:
magick 2.jpg -colorspace gray gray2.jpg
Then I can convert "grayscale" .jpgs to .pdf by simply:
magick gray2.jpg gray2.pdf
P.S.
If anyone has some better solution I will gladly accept it but if nothing shows up I am going to accept this
#fmw42
Here is a .zip file that contains
20.jpg - source image
20.pdf - corrupted pdf after running >magick 20.jpg 20.pdf
gray20.jpg - source image converted to gray by >magick 20.jpg -colorspace gray gray20.jpg
gray20.pdf - source image converted to .pdf after changing colorspace to gray first by >magick gray20.jpg gray20.pdf
Keep in mind that this image is from some weird manga but I have tried to pick the most normal page (it was harder than it seemed to be but this image itself is not nsfw)
I regularly scan in my Homework for class. My scanner exports raw jpg files to usb, and from there I can use gimp to edit and save the files as a pdf. One time saver I've found is to export my multi-page homeworks as a .mng file and then use the convert function to turn it into a pdf. I do it this way because Gimp automatically merges all layers when exporting to a pdf.
convert HW.mng HW.pdf
this works well for individual files, but at the end of every week I can have dozens of files to convert.
I have tried using wildcards in the filenames for convert:
convert *.mng *.pdf
This always runs successfully and never throws an error, but never produces any pdfs.
Both
convert HW*.mng HW*.pdf
and
convert "HW*.mng" "HW*.pdf"
yeild the error
convert: unable to open image `HW*.pdf': Invalid argument # error/blob.c/OpenBlob/2712.
which I think means the error lies in exporting with a wildcard.
Is there any way to convert all of a specific file type to another using convert? Or should I try using a different program?
You can see this StackExchange post. The accepted answer basically does what you want.
for file in *.mng; do convert -input "$file" -output "${file/%mng/pdf}"; done
For convert in particular, use mogrify (which is part of ImageMagick as well) as suggested by Mark Setchell in a comment. mogrify can be used to edit/convert files in batches. The command for your case would be
mogrify -format pdf -- *.mng
I am trying to extract motion vector data from an encoded mp4 file. In a previous post I found
an answer http://www.princeton.edu/~jiasic/cos435/motion_vector.c . But I am not able to run the code without errors . What are the other files that have to be included in the file ? I am a newbie here . So any help would be appreciated .
I had modified the source code of mplayer (ffmpeg) to extract motion vectors for any compressed video, I have uploaded the modified mplayer code which can be used for extracting motion vectors here http://www.cs.umd.edu/~bharat/modmplayer.zip
You need to do the following to extract motion vectors if you use the modified version of mplayer
./mplayer -nosound -fps 200 -vo null -lavdopts vismv=1 path_of_video_file 2> path_of_output_file.txt
Pre-compiled executable and some useful files are available in the outputs folder
I'm wanting to progress through a directory's subdirectories and either convert or place .TIF images into a pdf. I have a directory structure like this:
folder
item_one
file1.TIF
file2.TIF
...
fileN.TIF
item_two
file1.TIF
file2.TIF
...
...
I'm working on a Mac and considered using sips to change my .TIF files to .PNG files and then use pdfjoin to join all the .PNG files into a single .PDF file per folder.
I have used:
for filename in *; do sips -s format png $filename --out $filename.png; done
but this only works for the .TIF files in a single directory. How would one write a shellscript to progress through a series of directories as well?
once the .PNG files were created I'd do essentially the same thing but using:
pdfjoin --a4paper --fitpaper false --rotateoversize false *.png
Is this a valid way of doing this? Is there a better, more efficient way of performing such an action? Or am I being an idiot and should be doing this with some sort of software, like ImageMagick or something?
Try using the find command with the exec switch to call your image conversion solution. Alternatively, instead of using the exec switch, you could pipe the output of find to xargs. There is lots of information online about using find. Here's one example from StackOverflow.
As far as the image conversion, I think that really depends on your requirements for speed and efficiency. If you've verified the process you described, and this is a one-time process, and it only takes seconds or minutes to run, then you're probably fine. On the other hand, if you need to do this frequently, then it might be worth investing the time to find a one-step conversion solution that takes less time than your current, two-pass solution.
Note that, instead of two passes, you may be able to pipe the output of sips to pdfjoin; however, that would require some investigation to verify.
Is it possible to list the contents of a LZMA file (.7zip) without uncompressing the whole file? Also, can I extract a single file from the LZMA file?
My problem: I have a 30GB .7z file that uncompresses to >5TB. I would like to manipulate the original .7z file without needing to do a full uncompress.
Yes. Start with XZ Utils. There are Perl and Python APIs.
You can find the file you want from the headers. Each file is compressed separately, so you can extract just the one you want.
Download lzma922.tar.bz2 from the LZMA SDK files page on Sourceforge, then extract the files and open up C/Util/7z/7zMain.c. There, you will find routines to extract a specific archive file from a .7z archive. You don't need to extract all the data from all the entries, the example code shows how to extract just the one you are interested in. This same code has logic to list the entries without extracting all the compressed data.
I solved this problem by installing 7zip (https://www.7-zip.org/) and using the parameter l. For example:
7z l file.7z
The output has some descriptive information and the list of files in the compressed files. Then, I call this inside python using the subprocess library:
import subprocess
output = subprocess.Popen(["7z","l", "file.7z"], stdout=subprocess.PIPE)
output = output.stdout.read().decode("utf-8")
Don't forget to make sure the program 7z is accessible in your PATH variable. I had to do this manually in Windows.