Get from Ico-github-logo

Highlights from
savepng

  • savepng(CDATA,filename,va...
    SAVEPNG
  • benchmark_savepng.m
    % Benchmark savepng with reference to built-in imwrite and
  • View all files

4.0

4.0 | 1 rating Rate this file 9 Downloads (last 30 days) File Size: 71 KB File ID: #40384
image thumbnail

savepng

by

 

19 Feb 2013 (Updated )

savepng is a fast PNG image compression routine that outperforms MatLab's built-in imwrite

| Watch this File

File Information
Description

savepng is a very efficient PNG image compression MEX-routine that outperforms MatLab's built-in imwrite in compression times and produced file sizes. For a typical figure size at the default compression level, savepng is ~5.8 times faster, with file size only 17% bigger than imwrite. At the highest compression level, savepng is still ~2.8 times faster, with produced file sizes 15% smaller.
PNG encoding is based on public-domain MINIZ library.

Usage
savepng(CDATA,filename[,Compression])

Where,

* CDATA -- is a standard MatLab image m-by-n-by-3 matrix. This matrix can be obtained using getframe command or, for a faster implementation, undocumented hardcopy command
* filename -- file name of the image to write. Don't forget to add .png to the file name.
* Compression -- Optional input argument. This argument takes on a number between 0 and 4095 controlling the amount of compression to try to achieve with PNG file. 0 implies no compresson, fastest option. 4095 implies the most amount of compression, slowest option. Default value is 8.

Up-to-date version, a more detailed help, bugs/issues tracking can all be found here:
https://github.com/stefslon/savepng

Required Products MATLAB
MATLAB release MATLAB 7.13 (R2011b)
Other requirements C compiler
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
22 Oct 2014 Lianyuan Zheng

I have downloaded the savepng package and run benchmark_savepng on 2014a and it shows the following error message:

Error using savepng (line 45)
Sorry, auto-compilation failed.

Error in benchmark_savepng (line 66)
savepng(img.cdata,'example3.png',C(iC));

It seems the mex compile fails. Does someone has the same issue? If yes, how to correct it?

Thanks,
Lianyuan

20 Nov 2013 Stefan Slonevskiy

Thanks, Robert. I will fix this problem in the submission.

20 Nov 2013 Robert Oostenveld

The compilation of the miniz mex file fails on MATLAB version 8.0.0.783 (R2012b) Mac OS X 10.6.8:

>> benchmark_savepng
In file included from savepng.c:35:
miniz.c:2759: error: conflicting types for 'tdefl_write_image_to_png_file_in_memory'
miniz.c:794: error: previous declaration of 'tdefl_write_image_to_png_file_in_memory' was here
savepng.c: In function 'mexFunction':
savepng.c:68: warning: comparison is always false due to limited range of data type
savepng.c:68: warning: comparison is always false due to limited range of data type
savepng.c:120: warning: 'return' with a value, in function returning void

mex: compile of ' "savepng.c"' failed.

Error using savepng (line 34)
Sorry, auto-compilation failed.

Changing line 794 in miniz.c from

void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out);

into

void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int max_probes, int num_chans, size_t *pLen_out);

solves the problem.

Updates
29 Apr 2014

- fixed compiler errors, updated to latest miniz library, linked to GitHub

Contact us