Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Batch Crop to Content
#1
GIMP has a great feature where you can go to Image, Crop to Content.

Is there any way to Batch process this for many images so it crops and then saves the file? I have tried the plugin BIMP but this is not an option.

I believe you can create custom scripts but I do not know how to do this.


Thank you for any help you can provide.
Reply
#2
For BIMP you could try zealous crop which is an image equivalent (sometimes) of the layer, crop-to-content.

It does show in BIMP as an "Other GIMP procedure" as:

   

Thumbnails showing the resulting cropped images.

Otherwise, yes, for some Gimp procedures BIMP has a blacklist (save..etc) and you can often get around this using a script or plugin.
edit: I use the attached as a shell and slot commands in as required. Again it shows in "Other GIMP procedure" It is a python plugin, might be best if you try in Windows first.


Attached Files
.zip   for-bimp.zip (Size: 384 bytes / Downloads: 110)
Reply
#3
Thank you for the reply. I have tried that plugin. It does work but it also chages the inside of the image and removes the space rather than just cropping around the edges. Is does not work in the same way as the Image, Crop to Content tool.

It is a shame in BIMP that is no option for gimp-image-crop-to-content in the Other GIMP Procedures section. I will see if I can figure out the shell and slot command you mentioned
Reply
#4
(07-07-2024, 10:34 AM)gmpuser Wrote: Thank you for the reply. I have tried that plugin. It does work but it also chages the inside of the image and removes the space rather than just cropping around the edges. Is does not work in the same way as the Image, Crop to Content tool.

It is a shame in BIMP that is no option for gimp-image-crop-to-content in the Other GIMP Procedures section. I will see if I can figure out the shell and slot command you mentioned

I already popped in the for-bimp.py plugin the autocrop command. Download. Unzip and put in your User Profile Plugins folder You can try it on one of your problem images before using BIMP. It registers in the tools menu. In Bimp use Other Gimp procedure and search for bimp.

Example https://i.imgur.com/ZozQXG1.mp4 original -> zealous crop -> plugin. See if that is what you want.

If you give some deails of the type of image you want to process there might be other options such a gimp_gmic_qt plugin (ok for Windows might not for MacOS)
Reply
#5
Thank you for your help with this. That has worked for me, and the batch processing is working. I really appreciate that. It was the Tools, for bimp type of crop that I needed. I have been testing with a few images, and it is working. This will save a lot of time. Amazing and great work with the plugin you provided.

Do you know if there is a way to make sure the settings are set to maximum quality 100% when saving the JPG? The quality is slightly different from the original image.
Reply
#6
(07-07-2024, 02:11 PM)gmpuser Wrote: Do you know if there is a way to make sure the settings are set to maximum quality 100% when saving the JPG? The quality is slightly different from the original image.

Really, it all depends on the input quality. If the original is not great, then the output will be the same.

jpeg quality is not linear. 100% is still compressed, it is not lossless. 100% > 90% not a great change in quality just in file size. Then less than 50% the other way, loss of quality, same file size.

This is a typical quality <> size graph
https://stackoverflow.com/questions/4677...ompression

You can add add another BIMP procedure, Change Format and Compression. The default jpeg is 85 % so bump that up, or change to a lossless format such as png or depending on destination webp lossless.
Reply
#7
Thank you for the reply. Yes, I understand that. The issue is that the saved version after the batch process is of lower quality than the original. I want to keep it exactly the same as the original. In Photoshop, GIMP, and other programs you can set the quality to 100% of the original. I notice GIMP tends to use 98% as a default. When I zoom in on the images, there is noise and distortion, which is not in the original.

There are no settings to adjust the quality from 98 to 100 on the BIMP plugin. Do you know if there is any way to make sure this is set to 100 during the batch process?

Thank you for your help.
Reply
#8
Well, I kind of disagree.  When BIMP opens an image on file it is the same as Gimp, the image is the array of pixels as RGB.

You can adjust the output, using the Format and Compression procedure and bump the Jpeg quality up to 100% Or use a losslesss format.

   

If you want some other changes such as sharpening then add those before the final export.

Edit: Jpeg compression (from memory) works on blocks of 8x8 pixels. If the crop does not coincide exactly with the original 8x8 then it is a new re-encode and that might make a difference. Note The default Gimp jpeg export quality setting is 90. If 98 is showing then that is the value for the original jpeg.
Reply
#9
I have added an image to try to show you what I mean.

https://imgur.com/0RUGIuf

The images I am using are black text on a white background. You can notice the difference after the conversion. If you zoom in, the converted image has extra distortion around the text and is not the same as the original.

I did test the Format and Compression and saved it as JPG set at 100. This improves the quality, but it is still not the same as the original. I tried converting to PNG with 0 compression, and this keeps the same image quality from what I can see.

My original JPG files were from Photoshop, and an image was around 900 KB in size. The same image from the bimp plugin came out at 456 KB and with the JPG quality set to 100 is 733 KB so something is being removed. It may just be the cropped space reduceing the size. The PNG files are over 10 MB which is not ideal, but I do need to do further editing and can reduce this file size later with something like the RIOT tool.

I will test this further and see how it goes. Thank you for your help.

I have also noticed the JPG files I have exported from Photoshop will not read in the BIMP Plugin. When I open directly in GIMP it is asking to import the Image from a color profile. I may need to save them in a different way from Photoshop.
Reply
#10
(07-08-2024, 06:46 AM)gmpuser Wrote: I have added an image to try to show you what I mean.

https://imgur.com/0RUGIuf

The images I am using are black text on a white background. You can notice the difference after the conversion. If you zoom in, the converted image has extra distortion around the text and is not the same as the original.

I did test the Format and Compression and saved it as JPG set at 100. This improves the quality, but it is still not the same as the original. I tried converting to PNG with 0 compression, and this keeps the same image quality from what I can see.


I had a feeling yesterday, that small text might be involved. Jpeg compression artefacts. Even when jpeg quality is set to maximum, there is still compression. Jpeg is not lossless. This is some original text with the cropped version on top. Linear inverted colour to make the artefacts more visible. Toggle visibility on/off to see the two sets and finally difference mode to see all of them. https://i.imgur.com/z2FtOuZ.mp4 20 seconds so do not blink.

Quote: My original JPG files were from Photoshop, and an image was around 900 KB in size. The same image from the bimp plugin came out at 456 KB and with the JPG quality set to 100 is 733 KB so something is being removed. It may just be the cropped space reduceing the size. The PNG files are over 10 MB which is not ideal, but I do need to do further editing and can reduce this file size later with something like the RIOT tool.

PNG format is lossless. The png compression value changes the amount of effort involved in unpacking the file when it is opened. More compression, slower to open. There is also lossless tiff and if you want a smaller file size try webp which has both lossy and lossless options. RIOT will just strip out metadata then re-encode the jpeg and get a new set of compression artefacts.

Quote: I have also noticed the JPG files I have exported from Photoshop will not read in the BIMP Plugin. When I open directly in GIMP it is asking to import the Image from a color profile. I may need to save them in a different way from Photoshop.

That is strange. If you can post one of the original jpegs to check, (or maybe not 733 KB too large for an attachment) might help. PS is notorious for not following industry standards. I might pull out my old PS7 see if I can reproduce that.

Edit: Jpeg is really a finished format, not one to start editing with. Try exporting from PS as a tiff and leave the conversion to jpeg as the final procedure. The jpeg spec. does differentiate between greyscale and RGB. What mode your original images ?
Reply


Forum Jump: