Skip to main content

[JAI] Adding white border to images

2 replies [Last post]
Anonymous

Hi,

I've begun using JAI recently. The aim of the project is to
scale and crop images of any size to
a fixed width and height - thereby creating thumbnails (all
in the same size) of the images.
All is done automatically.
Now, for images which are smaller than the size I want for
my thumbnails, I need to have the option to either
1. scale up the image and then crop
2. don't scale up - instead add some white border where
needed (that is, merging the orginal image with some white
background). Then crop, if needed.

How can I achieve the second option using JAI?

/best regards, Håkan Jacobsson - System developer in Sweden

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Bob Deen

Welcome to JAI...

One option would be to use a BorderExtender to create the border. I've
not used it myself but you can look it up. Another approach which I
think is easier (but only because I haven't used BorderExtender ;-) )
would be to use the Constant operator to create a white image of the
right size, use Translate to put the thumbnail in the right relative
position, then use Overlay to combine them.

Good luck...

-Bob

H?n Jacobsson wrote:
> Hi,
>
> I've begun using JAI recently. The aim of the project is to
> scale and crop images of any size to
> a fixed width and height - thereby creating thumbnails (all
> in the same size) of the images.
> All is done automatically.
> Now, for images which are smaller than the size I want for
> my thumbnails, I need to have the option to either
> 1. scale up the image and then crop
> 2. don't scale up - instead add some white border where
> needed (that is, merging the orginal image with some white
> background). Then crop, if needed.
>
> How can I achieve the second option using JAI?
>
> /best regards, Håkan Jacobsson - System developer in Sweden
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Rafael Santos

Håkan,

For an example of the Border Operator see
https://jaistuff.dev.java.net/operators.html (search for "Border").

Rafael

>
> One option would be to use a BorderExtender to create the border.
> I've not used it myself but you can look it up. Another approach
> which I think is easier (but only because I haven't used
> BorderExtender ;-) ) would be to use the Constant operator to create
> a white image of the right size, use Translate to put the thumbnail in
> the right relative position, then use Overlay to combine them.
>
> Good luck...
>
> -Bob
>
> H?n Jacobsson wrote:
>> Hi,
>>
>> I've begun using JAI recently. The aim of the project is to
>> scale and crop images of any size to
>> a fixed width and height - thereby creating thumbnails (all
>> in the same size) of the images.
>> All is done automatically.
>> Now, for images which are smaller than the size I want for
>> my thumbnails, I need to have the option to either
>> 1. scale up the image and then crop 2. don't scale up - instead add
>> some white border where
>> needed (that is, merging the orginal image with some white
>> background). Then crop, if needed.
>>
>> How can I achieve the second option using JAI?
>>
>> /best regards, Håkan Jacobsson - System developer in Sweden
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
>> For additional commands, e-mail: interest-help@jai.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net