Automatically compress images

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

Automatically compress images

Post by onli » Sun Sep 11, 2016 11:17 pm

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 166 times

User avatar
Don Chambers
Regular
Posts: 3611
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: Automatically compress images

Post by Don Chambers » Thu Sep 15, 2016 5:07 am

I'll try to test this soon. You mentioned existing images would not be touched. Could that be an option?

User avatar
onli
Regular
Posts: 2160
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Automatically compress images

Post by onli » Thu Sep 15, 2016 10:08 am

It could be something on adds later. Currently it can't work well, you only have 500 free API-calls per month.

User avatar
Don Chambers
Regular
Posts: 3611
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: Automatically compress images

Post by Don Chambers » Fri Sep 16, 2016 3:51 am

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?

User avatar
yellowled
Regular
Posts: 6930
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany
Contact:

Re: Automatically compress images

Post by yellowled » Fri Sep 16, 2016 8:45 am

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
amazon Wishlist - Serendipity-Podcast (German only, sorry)

User avatar
onli
Regular
Posts: 2160
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Automatically compress images

Post by onli » Fri Sep 16, 2016 10:36 am

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: 228
Joined: Mon Jul 20, 2009 10:53 pm
Contact:

Re: Automatically compress images

Post by MarioH » Sat Sep 17, 2016 6:36 pm

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

User avatar
onli
Regular
Posts: 2160
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Automatically compress images

Post by onli » Sat Sep 17, 2016 7:34 pm

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: 228
Joined: Mon Jul 20, 2009 10:53 pm
Contact:

Re: Automatically compress images

Post by MarioH » Sat Sep 17, 2016 8:14 pm

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.

User avatar
onli
Regular
Posts: 2160
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Automatically compress images

Post by onli » Sun Oct 16, 2016 12:13 pm


Post Reply