# Define length and scale picture

Is there any program under linux where I can do the following:

Suppose I have for example a scan of a drawing on a squared paper and suppose that the squares of the original paper have any distance but not 0,5 cm.

Now I want that the squares of the output picture have a distance of exactly 0.5 cm.

I tried to include the picture to `inkscape` and use the ruler to rezize the picture appropriately but this was a pain.

I think something like this would be great: Have a "distance tool" where you can select two points of a picture (for example two vertices of my squared paper squares) then you define that the distance between those points should be say 0.5 cm then the whole picture should scale appropriately while preserving aspect ratios.

Note that I am mainly interested in a solution where I don't have to measure the distance on the original paper using a physical ruler or something like that.

Edit Finally I want a DIN A4 `pdf` including my picture and print it. In my example the point is that the distance of the squares should be 0.5 cm in the printed version...

-
i think you will save yourself huge headaches if you start thinking in terms of DPI (en.wikipedia.org/wiki/Dots_per_inch). – ixtmixilix Sep 17 '12 at 16:42
@ixtmixilix Does this help if I don't want to use a physical ruler for the original paper? – student Sep 17 '12 at 17:02

My answer starts where ixtmixilix comment ends and assumes that you have installed `ImageMagick`.

To get a pdf with the right resolution/density you need the margin/squares in Pixels, call it `p`. You can get this via `gimp`, `inkscape`, any other reasonable image editor/viewer or indirectly by the `dpi` of the used scanner multiplied by the real distance in `inch`.

If you want the new margin to be `x`cm's the formula for the resolution/density is

``````r = p / x
``````

To build the pdf you have to invoke

``````convert <your_picture> -density <r> -units PixelsPerCentimeter \
<your_pdfs_basename>.pdf
``````

Now you can print the pdf or embed the generated pdf in a latex document, etc. The previously adjusted resolution remains.

-
Just for completness: In `gimp` one can use the Measure Tool, in inkscape I don't know how to do it. – student Sep 17 '12 at 18:00
Thanks this works if I choose `pdf` as output format for the convert command as you suggested. Since I have to embed the result somewhere else to generate the final pdf I just tested do use `png` as output format and embed it in inkscape. However this doesn't work. Any idea why? – student Sep 17 '12 at 18:20
I found out that this is actually discussed on the inkscape bug tracker under the title png resolution not imported. It seems that several workarounds exists and a patch. Maybe you can find there further hints. – user1146332 Sep 17 '12 at 18:44
Is it also possible to modify the convert command to get the picture centered in an A4 pdf (without quality loss) – student Sep 17 '12 at 18:51
I don't know but you can adjust this via the standard gtk printer dialog. – user1146332 Sep 17 '12 at 18:56