Example Code

Resize PNG canvas

Code and Documents

Attachment

Overview

Resize PNG images by changing the DPI (Dots per meter for PNG files)

Description

Opens a PNG file and changes or add's the "Dots per meter" meta data of this file.

If you know the number of dots (x and y) then you can calculate how big the canvas should be.

Example:

x = 1000 dots

y = 500 dots

Picture should become 10x5 cm

x [dpm] = x [#dots] / size ----> 1000 [#dots] / 0.1 = 10000 [dpm]

y [dpm] = y [#dots] / size ---->  500 [#dots] /0.05 = 10000 [dpm]

* [dpm] = dots per meter, used by PNG files to determen the scale

Steps to Implement or Execute Code

  1. Select PNG file
  2. Calculate the dpm (dots per meter) needed, from the original file sizes
  3. file is converted (no data is changed ! only the physical size)

Requirements

Software

LV2013 sp1

ZLIB CRC32__ogtk.vi (openg)

Hardware

-

Additional Images or Video



Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors