Reputation: 33
I am currently working on an extension of a program, that generates an .eps file as intermediate result and then creates a PDF from it. Up until now, the program can only typeset text, but i want to include .jpg images. Since I haven't used Postscript before, i googled and found this post on how to include images: Simple way to add an image in postscript
I used this basic code and got something like this (Linebreaks added):
%!PS-Adobe-2.0
%%Creator: ...
%%Title: ...
%%Pages: 10
%%PageOrder: Ascend
%%BoundingBox: 0 0 595 842
%%EndComments
...
gsave
197.500000 571.000000 translate
200 137 scale
300.000000
137.000000
8
[500 0 0 -133 0 133]
(/home/.../Desktop/test.jpg) (r) file /DCTDecode filter
false
3
colorimage grestore
...
end
grestore
Now, as I understand the code, the image should always be 200 * 137 pixels. However, depending on the image I choose the size varies and I can't figure out why.
I tried to play with the values but I simply dont understand the behaviour on different images. I also tried to add EXIF resolution tags but they don't seem to have any affect whatsoever.
I also tried to find out what the array values do ([500 0 0 -133 0 133]) but I am still not quite sure.
I would expect the rendered image to be 200*137 pixels but it somehow depends on the input image.
Edit: The conversion is done with epstopdf -nosafer temp.ps -o=out.pdf
Upvotes: 1
Views: 741
Reputation: 33
As Luser Droog kindly suggested in the comment above, the problem was within the matrix. Detailed answer here: How include img in postscript
Basically just use [1 0 0 1 0 0]
or write the matrix like this:
["+ img_width +" 0 0 "+ -img_height +" 0 "+img_height+"]
Upvotes: 1