Hello,
i've a PHP mail module and want to send an image as attachment. No problem for this.
Want to limit attachment to 512 kb. Is there any way to convert an image with IM command ?
I know that I can script PHP to check size every conversion, but ask if exist any existing way to use IM natively.
thank you for any info,
m.
Resize image to specified size (kb)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resize image to specified size (kb)
If you convert the file to jpg, you can set the file size as per http://www.imagemagick.org/Usage/formats/#jpg
If on Linux, Mac OS or Windows with Cygwin, I have a script called downsize that you could try that is not restricted to jpg
Code: Select all
convert image -define jpeg:extent=512kb newimage.jpg
If on Linux, Mac OS or Windows with Cygwin, I have a script called downsize that you could try that is not restricted to jpg
Re: Resize image to specified size (kb)
thank you for reply,
reading around I find RIOT : http://luci.criosweb.ro/riot/
But IM is my choice for PHP integration.
Thank you again for help,
m.
reading around I find RIOT : http://luci.criosweb.ro/riot/
But IM is my choice for PHP integration.
Thank you again for help,
m.
Re: Resize image to specified size (kb)
Can the same limitation to the file size (kb) be made to a .tga file?
convert image -define jpeg:extent=512kb newimage.jpg
convert image -define jpeg:extent=512kb newimage.jpg
Re: Resize image to specified size (kb)
i tried changing the jpeg above to tga and the ending extension to .tga but it does not work.bair.sa wrote:Can the same limitation to the file size (kb) be made to a .tga file?
convert image -define jpeg:extent=512kb newimage.jpg
Re: Resize image to specified size (kb)
A list of the formats with their define options: http://www.imagemagick.org/script/comma ... php#define
tga does not seem to be on the list.
tga does not seem to be on the list.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resize image to specified size (kb)
The size limitation is currently only for JPEG as the define name implies. But if on Linux, Mac OSX or Windows with Cygwin, you can do that with my script, downsize, at the link below. It does not care about image format.
Re: Resize image to specified size (kb)
I had some issues with this helpful suggestion. Moved to viewtopic.php?f=1&t=29093fmw42 wrote:The size limitation is currently only for JPEG as the define name implies. But if on Linux, Mac OSX or Windows with Cygwin, you can do that with my script, downsize, at the link below. It does not care about image format.