Skip to content
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

Ushahidi should not upsize uploaded images, only downsize them. #1132

Merged
merged 2 commits into from
Aug 21, 2013
Merged

Ushahidi should not upsize uploaded images, only downsize them. #1132

merged 2 commits into from
Aug 21, 2013

Conversation

solarissmoke
Copy link
Contributor

When you upload an image with a report, it is forcibly resized to fit Ushahidi's large/medium/thumb formats. However this means that small images are upsized to fit these dimensions.

I am not sure if this is intentional, but it results in a lossy, pixelated image being saved, and it would be much better from a user experience perspective to just save and display the original image instead.

@rjmackay
Copy link
Contributor

rjmackay commented Jun 4, 2013

I think this makes sense. Just to confirm, this still saves images for media_link, media_medium and media_thumb? and saves valid filenames in the media table?
Could you just save the image once at full size and then reuse that url for all 3 sizes? (or 2 if its still big enough for medium)

- Don't save medium/thumbnails where the larger format is small enough.
- Don't upsize video thumbnails either.
@solarissmoke
Copy link
Contributor Author

@rjmackay it was saving three images (even if they were all the same size), but I have now changed it so that it reuses the larger format if it is small enough. The media table is populated correctly for each size (even when two sizes point to the same file).

For a 275 x 183 image, the following files are written to disk:

3_1_1370314420.jpg (full size, 275 x 183)
3_1_1370314420_t.jpg (thumbnail, 89 x 59)

a medium size image is not created because the full size one is small enough.

...and the media table looks like this:

media_link: 3_1_1370314420.jpg
media_medium: 3_1_1370314420.jpg (i.e., same as media_link)
media_thumb: 3_1_1370314420_t.jpg

Have also done the same thing for the video thumbnails.

@rjmackay
Copy link
Contributor

@aoduor @srutto Pretty sure this is good. Could one of you test this change?
Make sure to test both photo and video thumbnails and images of various sizes (otherwise you won't hit all the possible resize paths)

@rjmackay
Copy link
Contributor

I'm going to merge this.. but @srutto please flag this for testing in 2.7.1
ping @kamaulynder can you chase this too?

rjmackay added a commit that referenced this pull request Aug 21, 2013
Ushahidi should not upsize uploaded images, only downsize them.
@rjmackay rjmackay merged commit 45db962 into ushahidi:develop Aug 21, 2013
@srutto
Copy link
Contributor

srutto commented Aug 21, 2013

@rjmackay noted

@solarissmoke solarissmoke deleted the bug-image-upsizing branch August 29, 2013 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants