-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JPEG quality option #186
Comments
i hope this is better. |
@timomeara really appreciated your effort here, I just don't want to rush this. I agree that JPEG is probably the most likely of files this library supports. I think this could go two different ways. Ether you have attributes per mime type img = stdimage.StdImageField(variations={}, jpeg_attrs={}, png_attrs={}) or Both solutions have their pros and cons I guess. Maybe there is also a third one. Let me know what you think. |
hey- i'm not sure i understand the problems with either of the approaches i've submitted. i get the png does not support the quality param... but it just ignores it... it's a little ambiguous, but it won't break anything. a jpg_quality attrib is less ambiguous but that didn't fly either ;) what other attribs would you put in the png{} ? i'm setting optimize=True on everything, but i think that's what you were doing too, no? tmo |
ok, here is what I would recommend to do. I would create a subclass, a JPEG field that always saves the variations as JPEG. For this field you can of course add attributes that are JPEG specific. |
Please don't be discouraged. I do see the need for this feature. I am just very careful with adding new features, since I have to maintain them ;) |
to be a bit more precise what I am suggesting is: class JpegImageField(StdImageField):
"""Do whatever you want."""
pass |
hi, |
I agree fully. I am just waiting for someone to submit a patch ;) |
@codingjoe well this is how I see it: |
After pull #188 I use something like this to force all variations to be JPEGs. @classmethod
def process_variation(cls, variation, image):
img, kargs = super().process_variation(variation, image)
img = img.convert('RGB')
kargs['format'] = 'JPEG'
return (img, kargs)
@classmethod
def get_variation_name(cls, file_name, variation_name):
std_name = super().get_variation_name(file_name, variation_name)
path, _ = os.path.splitext(std_name)
return path + '.jpeg' By the look of it I think may be actual resampling also should be separate function. |
There is a |
something like this would be great:
'large': {'width': 354, 'height':270, 'crop':True, 'resample':True, 'jpg_quality':75}
The text was updated successfully, but these errors were encountered: