walterrowe / capture-one-scripts

User shared scripts for Capture One Pro raw photo editor
23 stars 3 forks source link

add_border bug #10

Closed lmoberly closed 2 months ago

lmoberly commented 1 year ago

I found that this script does not work when one of the pixel edges is greater than (around) 10000 pixels. Not totally sure why but rounding the calculated border size seems to work.

            if x is greater than y then -- set outer border width to 4% of shortest edge in pixels
                set border to padding + (4 / 100 * y)
            else
                set border to padding + (4 / 100 * x)
            end if

            set border to round (border) rounding up

I also changed the 4% width calculation which makes it easier to change the inner padding width. A two pixel inner border doesn't show up on a 100 megapixel picture.

Some of my professional programs hiccup with high pixel count photos, also. Today is the first time I've ever programmed AppleScript and I am timid about updating the code on GitHub.

walterrowe commented 1 year ago

Thanks for reporting this. I created a large image and experienced the issue. I added some display dialogs to show the calculated sizes. My original image was 12000 pixels wide. The width with inner border was displayed as 12004 pixels. When I displayed the width with calculated outer border this is what it showed.

Resolution w/ Outer Border: 1.2484E+4 x 4225.0 pixels

I suspect the 1.2484 was interpreted by sips as literally 1.2484 pixels wide vs 12484 pixels wide. I will see how to make sure this is sent to sips as an integer vs scientific notation.

walterrowe commented 1 year ago

I was able to resolve the issue by forcing all values to be integer. Download the updated copy.

lmoberly commented 1 year ago

Thanks, that’s more or less what I ended up doing. I still need to look at the sips command a little more because the current command defaults to a smaller bit depth, reducing the picture color quality. (That was the problem last week when I was trying to create a frame with python.)

Discovered your Magick Frames programs and will look at that for adding basic borders.

I’ve generally been adding frames with ON1 Photo, which basically adds a png layer over a photo. That program as I mentioned also has problems with large pixel pictures if you try to scale down big pictures inside the inner frame edge. I fix those by hand with GIMP, but that is the reason I started looking at pixel editing programing. Otherwise I am not at all a programmer.

Thanks for responding and providing your open source programs.

Larry

On Nov 27, 2022, at 6:01 AM, Walter Rowe @.***> wrote:

I was able to resolve the issue by forcing all values to be integer. Download the updated copy.

— Reply to this email directly, view it on GitHub https://github.com/walterrowe/capture-one-scripts/issues/10#issuecomment-1328253434, or unsubscribe https://github.com/notifications/unsubscribe-auth/AETGRTI6FQN2GP5LEOTZ6RDWKNSURANCNFSM6AAAAAASMH423Y. You are receiving this because you authored the thread.

walterrowe commented 1 year ago

The Magic Frames tool is superior to add_border in my opinion. It uses ImageMagick which preserves color profiles and bit depth. It doesn't do a simple border like add _border, but I think the types of borders it produces are more polished and attractive.

lmoberly commented 1 year ago

Hi Walter,

I spent the week playing with ImageMagick and your Frame_It scripts using my tif files and had a few comments.

Image Magick has issues with tif format (their notes imply there are a lot of variations). The primary problem I saw was that magick presumes/adds a thumbnail page/layer into the source file. To get frame_it to work with tiff I made these changes:

magick’s identify extraction of size width appends the sizes of the layers. It the width is 4000 pixels and the thumbnail width is 300 pixels, identify’s result for width is 4000300 pixels! This really mess-up your frame_it calculations. Changing the identify lines to:

         # extract image file width and height
         file_wide=$(identify -format %w "${source}""[0]")
         file_high=$(identify -format %h "${source}""[0]”)

pulls the dimensions from the ‘0’ layer. This change doesn’t seem to mess up jpeg of other picture formats.

For compiling the magick commands adding a '-delete 1' option reduces the source image to one layer, stripping the thumbnail:

                        magick "${source}" -delete 1 -auto-orient \
                             -mattecolor "${bevelcolor}" -frame ${bevel} \…………………

In a shell command you can type

        magick  'file_name.tif[0]’     -options      file_out.tif.        <———  needs the single quote

But I couldn’t get that same command to work in the frame_it script.

magick gives a few format warnings especially for Capture One tif’s.

magick strips out some, but not all of my exif data. I will probably need to add some exiftool steps to copy from the original picture.

I next need to set up a few simple borders (I don’t use watermarks) to have available for my workflow. And see if I can configure Image Magick to use openCL which hopefully will speed it up. Again thanks for the ‘introduction’ to Image Magick which seems like it might have more available capabilities than what I saw in Pythion (me, who doesn’t know any of these coding languages).

Regards, Larry

On Nov 27, 2022, at 9:01 AM, Walter Rowe @.***> wrote:

The Magic Frames tool is superior to add_border in my opinion. It uses ImageMagick which preserves color profiles and bit depth. It doesn't do a simple border like add _border, but I think the types of borders it produces are more polished and attractive.

— Reply to this email directly, view it on GitHub https://github.com/walterrowe/capture-one-scripts/issues/10#issuecomment-1328295141, or unsubscribe https://github.com/notifications/unsubscribe-auth/AETGRTOSHAKUNZBAJVATRZ3WKOHX5ANCNFSM6AAAAAASMH423Y. You are receiving this because you authored the thread.

walterrowe commented 1 year ago

Thanks for this very helpful information. I will create a separate issue on the magick frames project and incorporate this.

walterrowe commented 1 year ago

This issue in the ImageMagick project reflects XMP data being dropped. It appears that any extended XMP is dropped.

https://github.com/ImageMagick/ImageMagick/issues/4713

lmoberly commented 1 year ago

I did a quick check. I did not see significant differences for the magick exif/xmp output for JPEG's, but many differences and omissions for output TIFF files. Just using this in-out command:

magick picture.jpg. picture-IM.jpg. (for jpeg's) magick. picture.tif -delete 1 picture-IM.tif. (for tiff's, the option to get rid of the thumbnail page)

This operation loses a lot of the ExifIFD in the tiff files (stuff like F Number, ISO, Shutter Speed Value, Aperture Value,....) For jpegs all of the ExifIFD data is retained. Maybe it's to be expected that Image Magick has more problems with the tiff format.