[Dev-luatex] How to crop bitmap images

Patrick Gundlach patrick at gundla.ch
Mon Jul 1 21:10:21 CEST 2013


Hello Hans,


> best pack the img in a box and then put some qQ around it with the clip at the end (the usual experimenting with origin), so basically something compatible to
> 
> \pdfliteral {q clip spec}
> \pdfximage{...}
> \pdfliteral {Q}
> 
> ending up in something

that works fine, thank you very much! This is my test code now:

-----------------------
\directlua{
  a=node.new("whatsit","pdf_literal")
  b=node.new("whatsit","pdf_literal")
  a.data = "q 0 w 20 20 m 140  20 l 140 160 l 20 160 l W n "
  b.data = "Q"
  image = img.scan{filename="cow.pdf"}
  i = img.node(image)
  node.insert_after(a,a,i)
  node.insert_after(a,i,b)
  head = node.hpack(a)
  tex.box[0] = head
}


\box0

\bye
-----------------------

I wonder how it compares to the slightly different approach pdflatex uses (pdftex.def?). If I see it correctly the graphicx package creates an xobject/form from the bitmap and changes the bounding box there.


Thanks again!

Patrick



More information about the dev-luatex mailing list