Created attachment 151780 [details] Image to download When the local cover images are imported from very large photos or images, they do not seem to be worked before being put in the database. To reproduce: 1. Download the attached image large-image.jpg --> It should be ~170kB and 1000×1500 pixels 2. Enable LocalCoverImages in System preferences 3. Find a record in the staff interface 4. Go to "Images" tab 5. Upload large-image.jpg image 5.1. Click on "Upload" 5.2. Click on "Drop files here or click to select a file" 5.3. Choose picture (large-image.jpg) 5.4. Click on "Process images" 6. Click on image for large image 7. Right-click on the image and save it --> It is ~930kB and 600x900 pixels
Created attachment 151781 [details] [review] Bug 33857: Resize local cover images This patch add a script in ./misc/maintenance/ that allows to reduce and resize local cover images. Test plan: 1. Download the attached image large-image.jpg --> It should be ~170kB and 1000×1500 pixels 2. Enable LocalCoverImages in System preferences 3. Find a record in the staff interface 4. Go to "Images" tab 5. Upload large-image.jpg image 5.1. Click on "Upload" 5.2. Click on "Drop files here or click to select a file" 5.3. Choose picture (large-image.jpg) 5.4. Click on "Process images" 6. Click on image for large image 7. Right-click on the image and save it --> It is ~930kB and 600x900 pixels 8. Apply the patch 9. In the terminal, run the script resize_cover_images.pl 9.1. Before running the script you need to run the following lines --> sudo apt install imagemagick --> sudo apt install libimage-magick-perl 9.2. Run resize_cover_images.pl --> perl ./misc/maintenance/resize_cover_images.pl 10. Repeat steps 6 and 7 --> The image is ~200kB and 267x400 pixels
Created attachment 151810 [details] [review] Bug 33857: Add script to resize cover images Signed-off-by: Sam Lau <samalau@gmail.com>
I think there may be a problem with the signoff? It seemed to create a second patch without obsoleting the first? I don't know enough to pinpoint the reason, but I don't think that there should be two patches...
Created attachment 152307 [details] [review] Bug 33857: Add script to resize cover images
Created attachment 152308 [details] [review] Bug 33857: Change output messages
Created attachment 152313 [details] [review] Bug 33857: Change output messages
In my experience the problem arises from the change of format from JPEG to PNG. There should be a way to contain file size, without compromising pixel size. One could tamper for example with JPEQ quality index. Please see bug 33143 for examples.
Has noone noticed that in the test example we begin with a full size image (1000×1500 pixels) with a filesize of only ~170kB and after running resize_cover_images.pl we end up with a greatly reduced quality image (267x400 pixels) having an increased filesize? Is this sane practice, aren't we trying to reduce the filesize and its impact on database size? In the test example, we'd be better off leaving the image in its initial status. Please also check Bug 31049 - Add tool to set/reduce local cover image size and quality, interactively and in batch.
Manos is right, we should fix the original problem instead of doing this.
See bug 33143, bug 31049, bug 23963 and bug 22988.
(In reply to Jonathan Druart from comment #9) > Manos is right, we should fix the original problem instead of doing this. Why not use FQA to keep the queue cleaner?
(In reply to Jonathan Druart from comment #10) > See bug 33143, bug 31049, bug 23963 and bug 22988. Please consider voting for the bugs you consider important. It's available next to "Importance" drop-down list. FQA? https://www.acronymfinder.com/FQA.html
(In reply to Manos PETRIDIS from comment #12) > FQA? https://www.acronymfinder.com/FQA.html "Failed QA" in this context.
Created attachment 171103 [details] [review] Bug 33857: Avoid increasing file size while uploading image This patch prevents image size from increasing while uploading by keeping the original image format Test plan: 1. Download the attached image large-image.jpg --> It should be ~170kB and 1000×1500 pixels 2. Enable LocalCoverImages in System preferences 3. Find a record in the staff interface 4. Go to "Images" tab 5. Upload large-image.jpg image 5.1. Click on "Upload" 5.2. Click on "Drop files here or click to select a file" 5.3. Choose picture (large-image.jpg) 5.4. Click on "Process images" 6. Click on image for large image 7. Right-click on the image and save it --> It is ~930kB and 600x900 pixels 8. Apply the patch 9. Detele the previous uploaded image 10. Repeat step 3, 4, 5, 6, 7 --> The image is ~92kB and 600x900 pixels 11. prove t/db_dependent/Koha/CoverImages.t --> All tests should be successful
Hi Hinemoea, Thank you for working on this patch. I've failed QA because after applying the patch I am unable to upload images to records. I get this error message "Unable to save image to database." and weirdly there is a text box that appears below the "Drop files here or click to select a file" box.