Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Trying to make such things:

1st step:

convert img.jpg img.pdf

2nd step:

pdfimages -j img.pdf img1

Comparing source and extracted images in HEX shows difference. How to make such conversion without data loss?

share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

One way is to use pdflatex instead of convert.

You need in a extra file, which is here called image.tex:

\documentclass{article}
\usepackage[active,tightpage]{preview}
\usepackage{graphicx}
\PreviewMacro[{*[][]{}}]{\includegraphics}
\begin{document}
   \includegraphics{img.jpg}
\end{document}

Then run pdflatex image.tex to generate image.pdf.

share|improve this answer
    
works perfect. thank you –  Darkternal Mar 15 '12 at 12:38
add comment

Are you sure that there's an entire JPEG - metadata and picture data, in JFIF/JPEG format within the PDF? If not, then even if the image data is extracted verbatim, pdfimages will have to reconstruct the container and that may not match.

You can get a similar situation with audio files and tags etc. - you can't do sum comparisons if you change the metadata.

IN that situation, you need to calculate hashes for just the data portion, rather than the whole file.

share|improve this answer
1  
The approach with convert does really return a different picture. Comparing the images with gimp shows slight differences. With pdflatex as described in my answer, you get exactly the same image back - including the original metadata. –  jofel Mar 14 '12 at 12:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.