[Ipe-discuss] Importing an IPE document to a png file of fixed dimensions

Otfried Cheong ipe at otfried.org
Sun Mar 6 10:39:15 CET 2022


On Sun, Mar 6, 2022, at 09:35, Lluís Alemany-Puig via Ipe-discuss wrote:
> Now, I've been told that I have to send a png file of dimensions 
> 2500x1406 (I believe in pixels -- they didn't specify units) to one of 
> the conference organizers, so I thought I would make a stylesheet with 
> layout size 2500x1408, like this:
>
>> <?xml version="1.0"?>
>> <!DOCTYPE ipestyle SYSTEM "ipe.dtd">
>> <ipestyle name="poster_format">
>> <!-- layout size for the poster -->
>> <layout paper="2500 1408" origin="0 0" frame="2500 1408"/>
>> <! -- other stuff, like colors and such -->
>> </ipestyle>
>> 
> and then export the ipe file to a png. That, however, did not work 
> quite as expected: the exported png file did not have the same 
> dimensions as the layout. In fact, the png had different dimensions 
> depending on the zoom level on the canvas: e.g. the smaller I could see 
> the contents on IPE's GUI, the smaller (in dimensions) the png file. 

The physical dimensions of the Ipe document page are for PDF output - they really have nothing to do with the pixel resolution when you export to PNG.    As you noticed the pixel resolution depends on the zoom level.  The easiest way to achieve what you want would be to call 'iperender' from the command line:

iperender -png -resolution 72 -nocrop poster.ipe poster.png

The '-resolution 72' makes sure that you get a resolution matching what you set in your style sheet.   The '-nocrop' option makes sure that the whole page is exported, so that you get exactly 2500 x 1408 pixels. 

If you don't like the command line, you can export from inside Ipe *after* setting the zoom to exactly 72.  (Zoom -> Normal size does that, the lower right corner then displays "72ppi").   However, this will crop the image, so you need to add some object to fill the entire page, e.g. a white rectangle in the background.  (You can also put that rectangle in an extra layer named BBOX and make that invisible - it will still be counted for the cropping.)

Some remarks:

1. Often it is easier to choose a different physical size, so that the font sizes and symbolic sizes work well without redefining everything.   In your case, you could have set the paper size to be 1250 x 704, and then export at resolution 144.

2. You don't need to make a big new style sheet.  You could for instance use that standard presentation style sheet, and then just add another short style sheet that only changes the paper size:

<?xml version="1.0"?>
<!DOCTYPE ipestyle SYSTEM "ipe.dtd">
<ipestyle name="poster_format">
<layout paper="2500 1408" origin="0 0" frame="2500 1408" crop="no" />
</ipestyle>

Cheers,
  Otfried


More information about the Ipe-discuss mailing list