Maybe something like

BORDER=40
COLOR=.2,.2,.2,1.0
oiiotool input.tif --pattern constant:color=$COLOR 
"{TOP.width+2*$BORDER}x{TOP.height+2*$BORDER}" "{TOP.nchannels}" --paste 
"+$BORDER+$BORDER" -o output.tif

Note the use of oiiotool's {expression substitution} so that you don't need to 
know the resolution of the input image.

Breakdown:

oiiotool                    # you know what that is
    input.tif               # read input image, put it on the stack
    --pattern constant <size> <chans>   # push a constant-colored image on the 
stack
                                        #   note: at this point, input.tif is 
now
                                        #         the 2nd from top image.
    --paste <offset>        # paste the 2nd-from-top image on the top image
                            #     .. at the given offset coordinate
    -o output.tif           # write the result here

Details:

In expressions, TOP is the image currently on the top of the stack (that is, 
input.tif, since the constant image hasn't been pushed yet, when the arguments 
to --pattern are still being evaluated). So TOP.width, TOP.height, and 
TOP.nchannels are the resolution and number of channels of input.tif. 
Therefore, {TOP.width+2*$BORDER}x{TOP.height+2*$BORDER} will expand to 
something like "2000x1160" if input.tif was 1920x1080 and BORDER was set to 40.



> On Oct 17, 2021, at 7:00 AM, Mikael Sundell <mikael.sund...@gmail.com> wrote:
> 
> Hey all,
> 
> I’ve been away for some time and now playing with OpenImageIO and Lightroom, 
> is it possible to somehow generate a border around an image with something 
> like a resize 7-80% + fill with white/ black or any other color using the 
> command line tools?
> 
> Remember doing this in the past using olio c++ and Qt/ pixmaps.
> 
> Thanks :-)
> 
> Mikael
> 
> 
> Best regards,
> 
> Mikael Sundell
> mikael.sund...@gmail.com
> 
> _______________________________________________
> Oiio-dev mailing list
> Oiio-dev@lists.openimageio.org
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

--
Larry Gritz
l...@larrygritz.com




_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to