2 # -*- coding: ISO-8859-1 -*-
5 # Copyright (C) 2005 André Wobst <wobsta@users.sourceforge.net>
7 # epstopng is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # epstopng is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with epstopng; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 from optparse
import OptionParser
23 from pyx
import version
25 parser
= OptionParser(usage
="usage: %prog -o output-file [-r resolution] image-file",
26 version
="%prog " + version
.version
)
27 parser
.add_option("-o", "--output",
28 type="string", dest
="output",
30 parser
.add_option("-r", "--resolution",
31 type="string", dest
="resolution", default
=None,
32 help="resolution of the image in dpi (optional when available in the image data)")
33 (options
, args
) = parser
.parse_args()
35 parser
.error("can process a single image-file only")
38 im
= bitmap
.jpegimage(args
[0])
41 im
= Image
.open(args
[0])
42 compressmode
= "Flate"
45 if options
.resolution
is None:
48 width
= im
.size
[0] / float(options
.resolution
) * unit
.inch
50 c
.insert(bitmap
.bitmap(0, 0, im
, compressmode
=compressmode
, width
=width
))
51 c
.writetofile(options
.output
)