RSS/Atom feed Twitter
Site is read-only, email is disabled

crop to content

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

17 of 17 messages available
Toggle history

Please log in to manage your subscriptions.

crop to content geop 30 Jan 19:44
  crop to content Liam Quin 30 Jan 20:44
   crop to content geop 30 Jan 22:09
    crop to content Liam R E Quin 30 Jan 23:33
     crop to content geop 31 Jan 18:53
     crop to content gimp-users.mbourne@spamgourmet.com 31 Jan 21:47
      crop to content Liam R E Quin 01 Feb 03:04
       crop to content geop 01 Feb 15:44
        crop to content geop 01 Feb 18:59
        crop to content rich404 01 Feb 19:47
         crop to content geop 02 Feb 16:01
          crop to content geop 02 Feb 18:25
           crop to content geop 02 Feb 22:41
    crop to content rich404 31 Jan 12:45
     crop to content geop 31 Jan 19:22
   crop to content Gary Aitken 31 Jan 04:12
    crop to content geop 31 Jan 18:55
2020-01-30 19:44:59 UTC (almost 5 years ago)
postings
10

crop to content

I have scanned photographs which have a white border. I try "Crop to content" and get the following popup:

"Cannot crop because the image is already cropped to its content."

The border is unchanged.

I thought that possibly there are some pixels on the outer edge of the border that are confusing the crop, so I manully removed the outer edges of the border and tried "crop to content" again. Same result.

What am I missing here?

Attachments: * https://www.gimpusers.com/system/attachments/1353/original/two-women-300dpi-compr2-80.jpg

geop (via www.gimpusers.com/forums)
Liam Quin
2020-01-30 20:44:42 UTC (almost 5 years ago)

crop to content

On Thu, 2020-01-30 at 20:44 +0100, geop wrote:

I have scanned photographs which have a white border. I try "Crop to content"

Crop to content removes outside borders of picels which all have exactly the same value but your border, although whiteish, is not like that.

Rotate the image -- the easiest and fastest way is to use tool options, turn on reverse/corrective mode, and turn on a grid "number of lines", and change the number of lines until one lines up with the a vertical edge in the border; drag the lines to rotate them a little and get the grid line to match as well as possible, and then in case the image isn't actually perfectly square, repeat for the top and bottom inner border edges, then finally press Enter to do the rotation.

Then crop the iamge with the crop tool to get rid of the border, if that's what you want, or to keep it, image->flatten image, then use rectangle select to select the inner pictiure, select->invert to change it to select the border, select->feather by 5px or so to make the edge soft, and drag the white swatch from the toolbox into the selection (if you don't have the default black and white, press d or click the black/white icon that's near the swatch).

slave

PS: clean the prints with a microfibre cloth, and the top of the scanner with that and eyeglass cleaner )spray onto the cloth of course, notthe scanner, and not the same cloth you use for prints; you can also use a special Japanese roller that was made for cleaning gramaphone records, https://amzn.to/2U9jN3R - but i worry that it may lift the surface of the print.

Liam Quin - web slave for https://www.fromoldbooks.org/
with fabulous vintage art and fascinating texts to read.
Click here to have the slave beaten.
2020-01-30 22:09:14 UTC (almost 5 years ago)
postings
10

crop to content

Hi - thanks for the quick reply. I wondered if it had to do with the slight non-uniformity of the pixel color in the border. I appreciate all your advice, but I really wanted an "automatic" process because I have a LOT of these bordered photos, and hoped to batch process them.

I see what you mean about rotation. My sample image is very slightly rotated, and I would think my other images all have some version of the same issue. I can tolerate that as these images are for family archives.

I should have mentioned that my main goal in eliminating the borders was so I could use, in a batch process, Auto - White Balance to remove color casts from many of the old B&W or color photos. From experimenting, the white border seemed to mess this up. Without the border, the White Balance result seemed usually "good enough" for my purpose.

So maybe I can suggest (somewhere) to the developers to add some parameters that permit some range in values for the border color in "Crop to content".

Thanks again! I now understand what the issues are.

geop (via www.gimpusers.com/forums)
Liam R E Quin
2020-01-30 23:33:29 UTC (almost 5 years ago)

crop to content

On Thu, 2020-01-30 at 23:09 +0100, geop wrote:

So maybe I can suggest (somewhere) to the developers to add some parameters that
permit some range in values for the border color in "Crop to content".

Once you do this you start eating into the main image, but it might be an interesting option to have a "shrink wrap" option in rectangle select or image crop, with a tolerance. Maybe there's already a script or plugin that does this.

Auto white balance loses a little bit of detail. I'm not sure whether rawtherapee or darktable has a way to do this - i tend to scan in 16bit greyscale for things like this (although scanning in colour can make it easier to remove dirt using the mono mixer and choosing blue and/or green channels). Bt i'musually scanning to sell the pictures on fromoldbooks.org.

The scanner i have came with holders for film strips and software for Windows (silverfast i think) that knew about the holders and identified all the photos automatically, a huge time saver.

If you can do a little scriptng you could maybe simply take a sample of the middle of the image, use that for white balance, and then undo (in the script) and apply the settings to the whole image.

It seems likely someone else has already done this, too...

slave

Liam Quin - web slave for https://www.fromoldbooks.org/
with fabulous vintage art and fascinating texts to read.
Click here to have the slave rewarded with extra work.
Gary Aitken
2020-01-31 04:12:32 UTC (almost 5 years ago)

crop to content

On 1/30/20 1:44 PM, Liam Quin wrote:

On Thu, 2020-01-30 at 20:44 +0100, geop wrote:

I have scanned photographs which have a white border. I try "Crop to content"

Crop to content removes outside borders of picels which all have exactly the same value but your border, although whiteish, is not like that.

Rotate the image -- the easiest and fastest way is to use tool options, turn on reverse/corrective mode, and turn on a grid "number of lines", and change the number of lines until one lines up with the a vertical edge in the border; drag the lines to rotate them a little and get the grid line to match as well as possible, and then in case the image isn't actually perfectly square, repeat for the top and bottom inner border edges, then finally press Enter to do the rotation.

Then crop the iamge with the crop tool to get rid of the border, if that's what you want, or to keep it, image->flatten image, then use rectangle select to select the inner pictiure, select->invert to change it to select the border, select->feather by 5px or so to make the edge soft, and drag the white swatch from the toolbox into the selection (if you don't have the default black and white, press d or click the black/white icon that's near the swatch).

slave

PS: clean the prints with a microfibre cloth, and the top of the scanner with that and eyeglass cleaner )spray onto the cloth of course, notthe scanner, and not the same cloth you use for prints; you can also use a special Japanese roller that was made for cleaning gramaphone records, https://amzn.to/2U9jN3R - but i worry that it may lift the surface of the print.

This is probably too simple a solution, but... If the images are all the same size, and have roughly the same border, can't you specify a rectangle select of a size slightly smaller to eliminate the border, position it at the proper offset, and crop? Or if the images are different sizes, compute a rectangle for e.g. 98%?

Gary

rich404
2020-01-31 12:45:11 UTC (almost 5 years ago)

crop to content

Hi - thanks for the quick reply. I wondered if it had to do with the slight
non-uniformity of the pixel color in the border. I appreciate all your advice,
but I really wanted an "automatic" process because I have a LOT of these
bordered photos, and hoped to batch process them.

I see what you mean about rotation. My sample image is very slightly rotated,
and I would think my other images all have some version of the same issue. I can
tolerate that as these images are for family archives.

I should have mentioned that my main goal in eliminating the borders was so I
could use, in a batch process, Auto - White Balance to remove color casts from
many of the old B&W or color photos. From experimenting, the white border seemed
to mess this up. Without the border, the White Balance result seemed usually
"good enough" for my purpose.

So maybe I can suggest (somewhere) to the developers to add some parameters that
permit some range in values for the border color in "Crop to content".

Thanks again! I now understand what the issues are.

Depends on your images but you might get away with the old divide-scanned-images script. There are various enhanced versions but the original is worth a try.

Usually as its name, split up a page with several images but a single image works.

Can be used individually or in a batch mode. Quick video demo, duration 2 minutes, using the batch function.

https://youtu.be/Ozc5WnlMnWY

Attachments: * https://www.gimpusers.com/system/attachments/1354/original/DivideScannedImages.scm

rich404 (via www.gimpusers.com/forums)
2020-01-31 18:53:16 UTC (almost 5 years ago)
postings
10

crop to content

Just starting on this project, so I need to check on greyscale scanning of greyscale images with color casts, versus color scanning with post-processing to correct. So for now I'll put aside the greyscale images and just consider color ones.

I'm scanning with a Fujitsu ScanSnap ix500. The automatic document feeding is great. I does de-skewing, but I guess based on the sample image I posted, I now realize it's not perfect in that respect.

I was not aware of rawtherapee or darktable. Will look around there some more.

I read more about how white balance is actually done - with multipliers - so I now understand how that can blow out highlights in the red and blue channels. Still might be OK for most images in a batch process, but of course I would check each image and set aside those that need extra work.

I need to check the suggestion in the reply from rich404 - maybe one of the scripts will do a "shrink wrap".

About your suggestion of doing auto white balance on a sample from the middle image - where do I find in Gimp what new multipliers it chose?

geop (via www.gimpusers.com/forums)
2020-01-31 18:55:32 UTC (almost 5 years ago)
postings
10

crop to content

Yes, there are certainly plenty of groups of images that are the same size, so this could work.

This is probably too simple a solution, but... If the images are all the same size, and have roughly the same border, can't you specify a rectangle select of a size slightly smaller to eliminate the border, position it at the proper offset, and crop? Or if the images are different sizes, compute a rectangle for e.g. 98%?

Gary

geop (via www.gimpusers.com/forums)
2020-01-31 19:22:17 UTC (almost 5 years ago)
postings
10

crop to content

Wow, Rich, just watched your video. Didn't realize until I start watching that you had made a custom video using my image! Thanks!

On that image, the script worked extremely well, judging from the final image in your video.

I see that the script file contained a link to a page describing how to install it in Gimp. Unfortunately, I have other things I need to do now but I'll set it up later on and give it a shot. Looks VERY promising.

geop (via www.gimpusers.com/forums)
gimp-users.mbourne@spamgourmet.com
2020-01-31 21:47:57 UTC (almost 5 years ago)

crop to content

Liam R E Quin wrote:

On Thu, 2020-01-30 at 23:09 +0100, geop wrote:

So maybe I can suggest (somewhere) to the developers to add some parameters that
permit some range in values for the border color in "Crop to content".

Once you do this you start eating into the main image, but it might be an interesting option to have a "shrink wrap" option in rectangle select or image crop, with a tolerance. Maybe there's already a script or plugin that does this.

I'm no expert, but it seems that it should be possible to use the fuzzy select tool (with adjustable threshold) to select the border, then Select > Invert and Image > Fit Canvas to Selection? Still with the caveat that it may eat into the wanted image.

Mark.
Liam R E Quin
2020-02-01 03:04:57 UTC (almost 5 years ago)

crop to content

On Fri, 2020-01-31 at 21:47 +0000, gimp-users.mbourne@spamgourmet.com wrote:

I'm no expert, but it seems that it should be possible to use the fuzzy
select tool (with adjustable threshold) to select the border,

With a large enough threshhold to get most of the border this will probably get part of the image inside; in addition, hairs and dirt on the surface of the print make it hard.

It's possible to combine this with select->grow, but that's not really easy to automate.

slave

then
Select > Invert and Image > Fit Canvas to Selection? Still with the caveat that it may eat into the wanted image.

Liam Quin - web slave for https://www.fromoldbooks.org/
with fabulous vintage art and fascinating texts to read.
Click here to have the slave beaten.
2020-02-01 15:44:37 UTC (almost 5 years ago)
postings
10

crop to content

Late last night I got the latest version of the script suggested by Rich and tried it on a dozen color photo scans with borders. Each was left with thin "white" strips along the sides and top and bottom, mostly thicker at one end than the other, indicating there was still a little skew left in the images (though the script does a deskew). I'll need to vary the parameters, and also try the original version of the script that Rich used.

I also tried the fuzzy select idea. With its default parameter (15, I think), and using the greyscale photo I sent earlier, this selected a lot of sky area. However, I did not get much further because I'm not familiar enough with Gimp. I did open the fuzzy settings and lower the value, but nothing changed, so it was unclear to me that was really the result, or that I had failed to completely confirm the new parameter somehow. But now I'm in a situation where I can NOT get to the fuzzy select settings any more, even on a Gimp restart! Arggh.

geop (via www.gimpusers.com/forums)
2020-02-01 18:59:08 UTC (almost 5 years ago)
postings
10

crop to content

Figured out my issues with fuzzy select and now know how to use it. Now after lots of experimenting just with that sample greyscale photo, I conclude it does NOT work well for my purpose. There is apparently too much variation in the border area, so a low threshold does not get all of the border, and a higher threshold eats into the image.

With the color picker, I found tone ranges in the border from 238 to 255. I tried to pick midrange "starting pixels" for the fuzzy select, but one can't really know if you clicked on exactly the right one.

The script still seems to have the most potential.

geop (via www.gimpusers.com/forums)
rich404
2020-02-01 19:47:36 UTC (almost 5 years ago)

crop to content

Late last night I got the latest version of the script suggested by Rich and
tried it on a dozen color photo scans with borders. Each was left with thin
"white" strips along the sides and top and bottom, mostly thicker at one end
than the other, indicating there was still a little skew left in the images
(though the script does a deskew). I'll need to vary the parameters, and also
try the original version of the script that Rich used.

@geop

The divide scanned images script can use a separate compiled plugin deskew.exe but no guarantee it will work correctly. Even older than the script. I have tried it in Win10 and it does work (I usually use linux)

However going by the sample image, that is not the problem, the actual picture area is not rectangular, if the side is vertical the top is not horizontal. Your scanner has already made a good job of de-skewing. I think you already know this.

If you can get it down to a minimum border, then any excess can be trimmed. Manually it is: Select All - Stroke Selection - Zealous Crop - Select None

I have knocked up a small python script (trim_it.py) to apply that procedure. It trims off about 8 pixels from the edges. Edit the script for more / less. Find bottom of the tools menu.

If you need to batch, then it is either run in command line, or use in the only up-to-date GUI Gimp batch plugin BIMP see: https://alessandrofrancesconi.it/projects/bimp/

Attached the two plugins zipped.

Unzip and put both in C:\Users\"yourname"\AppData\Roaming\GIMP\2.10\plug-ins

Attachments: * https://www.gimpusers.com/system/attachments/1355/original/trim.zip

rich404 (via www.gimpusers.com/forums)
2020-02-02 16:01:33 UTC (almost 5 years ago)
postings
10

crop to content

Running behind on trying things but here's an update.

I zoomed in on the photos processed by the version of the script I used (the "new"version), and there is a 3-pixel-wide strip (of varying intensity and color, if a color image) all around the edges that causes the visible artifacts I see.

@rich404 I did not get to try it yet, but I expect that edge is what your trim script would remove, with a setting of 3. I don't exactly understand yet how your script works, but when I read about zealous crop, it seemed a bit risky.

Instead I tried "select all", brought up the rectangle select tool options, then clicked inside the image to transfer the size and position info into the options. From there, I could manually reduce the offsets by 3 and sizes by 6. Then my lack of Gimp experience appears, because "Crop" does not remove the pixels outside of the selection! I need to figure that out. However, this could lead to a straightforward zealous-free way of cleaning up the script result.

Still need to try Rich's trim, and the original script.

@rich404 BTW, the new version script came with a deskew,exe but had me install it elsewhere. It came from http://francoismalan.com. You can find it by searching for "How to batch separate & crop multiple scanned photos".

@rich404 Regards bimp - I actually installed it the day before posting here, figuring I would need it. Have yet to try it though.

geop (via www.gimpusers.com/forums)
2020-02-02 18:25:11 UTC (almost 5 years ago)
postings
10

crop to content

Then my lack of Gimp experience appears, because "Crop" does not remove the pixels outside of the selection!

OK, figured that out. Had to use "Crop to selection" from Image menu instead of Crop from Tools - Transform Tools.

geop (via www.gimpusers.com/forums)
2020-02-02 22:41:59 UTC (almost 5 years ago)
postings
10

crop to content

I found the simpler way to trim the 3 pixels from the edge. Select - All, then Select - Shrink, specifying the 3 pixels.

geop (via www.gimpusers.com/forums)