Automatically compress images

Creating and modifying plugins.
Post Reply
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Automatically compress images

Post by onli »

There are some ways to compress images. JPGs lose quality, but PNGs support lossless compression. TinyPNG is one of several services that does that with sound defaults.

I made a plugin for it. It will automatically compress each image (.png or .jpg), directly after the upload. Already uploaded images won't be touched.

It would be great if this could be further tested before going to spartacus :) I also take feature requests.
Attachments
serendipity_event_tinypng-0.1.tar.gz
(148.72 KiB) Downloaded 2703 times
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Automatically compress images

Post by Don Chambers »

I'll try to test this soon. You mentioned existing images would not be touched. Could that be an option?
=Don=
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Automatically compress images

Post by onli »

It could be something on adds later. Currently it can't work well, you only have 500 free API-calls per month.
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Automatically compress images

Post by Don Chambers »

onli wrote:It could be something on adds later. Currently it can't work well, you only have 500 free API-calls per month.
Who only has 500 free API calls per month?
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Automatically compress images

Post by yellowled »

Don Chambers wrote:Who only has 500 free API calls per month?
The developer API for the TinyPNG web interface.
You only pay for what you use. The first 500 compressions each month are free. You will only be billed if you compress more than 500 images.
I assume every plugin user will have to get their own API key, otherwise it doesn't really make sense (to me).

YL
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Automatically compress images

Post by onli »

yellowled wrote:I assume every plugin user will have to get their own API key, otherwise it doesn't really make sense (to me).
Yes. The description of the API Key option explains where to get the key. Without it won't work.
MarioH
Regular
Posts: 238
Joined: Mon Jul 20, 2009 10:53 pm
Contact:

Re: Automatically compress images

Post by MarioH »

Hi,

I just get this error when uploading an image with the new plugin installed:

Fatal error: Call to undefined function Tinify\curl_version() in /var/www/vps.hommel-net.de/serendipity/plugins/serendipity_event_tinypng/tinify-php/lib/Tinify/Client.php on line 11

The image is in the media library after this error but it's not compressed.

Regards
Mario
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Automatically compress images

Post by onli »

Is it possible that you have no php curl module active? A package like php-curl?

I will have a look whether the Tinyfy-Client really needs it, but that is possible.
MarioH
Regular
Posts: 238
Joined: Mon Jul 20, 2009 10:53 pm
Contact:

Re: Automatically compress images

Post by MarioH »

That was the thing. The debian package is php5-curl. After installing it the error is gone.
It seems that the API of TinyPNG has counted my tries with the error, too.
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Automatically compress images

Post by onli »

Post Reply