[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: resize pictures received by mailserver



On 06/13/2012 02:36 PM, Tony van der Hoff wrote:
On 13/06/12 12:45, Randall wrote:
hi all,

have a question, not really debian specific, but looking for the tools
available in debian to do the job.

as follows:

i'm trying to set up a private synchronised  mailinglist/forum.
(thinking of a combination of mailman and tiki forum) and i want to
avoid having huge pictures showing up on the mailinglist/forum, since
most receivers have slow connections with huge latency etc...

one option would be to set a restriction on received sizes and do some
training of the users sending the mails and the harmonizing the mail
clients used etc....
but nowadys everybody uses different mobile devices etc.. to take and
send the pictures.

taking this approach will turn me into a hated drill sergeant... not my
favorite job..


so i figured there should be a way of less social resistance and more
user comfort.

is it possible to have all messages received by the mailinglists MTA
scanned for pictures and have these automatically scaled to a default
size before its being redistributed to the receivers on the mailinglist
and subsequently the forum.


my idea was that it could basically follow the same route as spam/virus
scanners, but i can't seem to find any available tools for this, never
came across it by accident or my googling skills are lacking.

anybody a hint?

much obliged

I use a combination of cjpeg, djpeg, and pnmscale to handle this.
Here is a snippet of PHP. Excuse the wrapping.

if ( !move_uploaded_file( $file['tmp_name'], $filename.".jpg" ) )
	trigger_error( "Possible file upload attack. File ".$file['name'] );
if ( system( "/usr/local/bin/djpeg ".$filename.".jpg>  ".$filename.".pnm
2>>  ../errlog.txt" ) == "FALSE" )
trigger_error( "failed to decompress ".$filename.".jpg" );
	if ( system( "/usr/local/bin/pnmscale -xysize 110 140 ".$filename.".pnm
".$filename."1.pnm 2>>  ../errlog.txt" ) == "FALSE" )
	trigger_error( "failed to scale ".$filename.".pnm" );
if ( system( "/usr/local/bin/cjpeg -smooth 10 -qual 50
".$filename."1.pnm>  ./images/users/".$userid.".jpg 2>>  ../errlog.txt" )
== "FALSE" )
			trigger_error( "failed to compress ".$filename."1.pnm" );




thanks,
could be a very usable piece of code.
this would be called when uploading pictures to a website i assume?



Reply to: