jakewaldron / PlexEmail

This script aggregates all new TV, movie and music releases for the past configured time then optionally writes to your web directory and sends out an email.
206 stars 32 forks source link

Request - Help with Cloudinary/JPEGmini Image Compression #17

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hello, great piece of software works very well. I was hoping for a bit of assistance using JPEGmini to adjust the quality of the files so they load a bit more quickly in emails accessed via mobile. I read this article here:

http://cloudinary.com/blog/optimize_your_jpeg_images_without_compromising_quality_with_jpegmini_and_cloudinary

It looks like "/q_90/" added to the upload URL will reduce the quality and help a bit. I am not sure where to even begin in adding this to the plexemail.py script. Could you provide me with a bit of direction when you have a moment? Thanks again for a great script!

ebright commented 8 years ago

You may wanna look at lines 301 - 311

def uploadToCloudinary(imgToUpload): if (os.path.isfile(imgToUpload)): if (os.path.islink(imgToUpload)): imgToUpload = os.path.realpath(imgToUpload) if (imghdr.what(imgToUpload)): response = cloudinary.uploader.upload(imgToUpload) return response['url'] else: return '' else: return ''

I would start here and check the url that is returned. You maybe able to edit that url to add the /q_90/

jakewaldron commented 8 years ago

I looked through the documentation on how to do this through their library that PlexEmail is using and it looks like by default it is already using 90%:

http://cloudinary.com/documentation/image_transformation_reference#quality_parameter

Control the JPEG, WebP, GIF, JPEG XR and JPEG 2000 compression quality. 1 is the lowest quality and 100 is the highest. Reducing quality generates JPG images much smaller in file size. The default values are:

  • JPEG: 90
ghost commented 8 years ago

Ah, thank you for taking the time to look through this for me. Looks like we are getting about all the compression from cloudinary we will! Thank you!