Skip to main content

Image Generation for varying sizes.

3 replies [Last post]
smp
Offline
Joined: 2007-08-22

Hi,

I am writing an image generation web app. The user can request an image from a set of different sizes (small, medium, etc.) and have a custom text (for logo), format, etc, etc. Here is what I was doing.On request I am creating an image of some default width and height and drew some graphic objects (string, etc with some hard-coded font size and stroke size) that fits perfectly.
then finally using AffineTransform.to get image of the required size from the previously generated image. If the requested dimensions are closer to my defaults then the image is ok, otherwise its blurred. How to get around this?
Ideally I would like to create the image from start with the requested dimensions then I need a way to figure out what appropriate fontsize and stroke etc. to be used for various graphic objects within the image. Is there a way?
Also how do we justify text (center, etc.) in an image?

thanks.

Reply viewing options

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

Regarding text and 2D graphics I recommend the Java 2D mailing list
java2d-interest@java.sun.com.

As for image resizing in JAI, for zooming "Scale" or "AffineTransform" are the
appropriate operations and for reducing "SubsampleAverage" is probably the
best choice.

On Mon, 27 Aug 2007, jai-imageio@javadesktop.org wrote:

> Hi,
>
> I am writing an image generation web app. The user can request an image from a set of different sizes (small, medium, etc.) and have a custom text (for logo), format, etc, etc. Here is what I was doing.On request I am creating an image of some default width and height and drew some graphic objects (string, etc with some hard-coded font size and stroke size) that fits perfectly.
> then finally using AffineTransform.to get image of the required size from the previously generated image. If the requested dimensions are closer to my defaults then the image is ok, otherwise its blurred. How to get around this?
> Ideally I would like to create the image from start with the requested dimensions then I need a way to figure out what appropriate fontsize and stroke etc. to be used for various graphic objects within the image. Is there a way?
> Also how do we justify text (center, etc.) in an image?
>
> thanks.
> [Message sent by forum member 'smp' (smp)]
>
> http://forums.java.net/jive/thread.jspa?messageID=232786

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

robert engels

Don't scale. Generate the image at the requested size, and then using
an appropriate transform perform the graphics operations.

You need to perform you only layout, but SwingUtilities has some
methods to help.

On Aug 27, 2007, at 2:55 PM, jai-imageio@javadesktop.org wrote:

> Hi,
>
> I am writing an image generation web app. The user can request an
> image from a set of different sizes (small, medium, etc.) and have
> a custom text (for logo), format, etc, etc. Here is what I was
> doing.On request I am creating an image of some default width and
> height and drew some graphic objects (string, etc with some hard-
> coded font size and stroke size) that fits perfectly.
> then finally using AffineTransform.to get image of the required
> size from the previously generated image. If the requested
> dimensions are closer to my defaults then the image is ok,
> otherwise its blurred. How to get around this?
> Ideally I would like to create the image from start with the
> requested dimensions then I need a way to figure out what
> appropriate fontsize and stroke etc. to be used for various graphic
> objects within the image. Is there a way?
> Also how do we justify text (center, etc.) in an image?
>
> thanks.
> [Message sent by forum member 'smp' (smp)]
>
> http://forums.java.net/jive/thread.jspa?messageID=232786
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-
> imageio.dev.java.net
>

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

Brian Burkhalter

This is the right idea ...

On Mon, 27 Aug 2007, robert engels wrote:

> Don't scale. Generate the image at the requested size, and then using an
> appropriate transform perform the graphics operations.
>
> You need to perform you only layout, but SwingUtilities has some methods to
> help.
>
> On Aug 27, 2007, at 2:55 PM, jai-imageio@javadesktop.org wrote:
>
>> Hi,
>>
>> I am writing an image generation web app. The user can request an image
>> from a set of different sizes (small, medium, etc.) and have a custom text
>> (for logo), format, etc, etc. Here is what I was doing.On request I am
>> creating an image of some default width and height and drew some graphic
>> objects (string, etc with some hard-coded font size and stroke size) that
>> fits perfectly.
>> then finally using AffineTransform.to get image of the required size from
>> the previously generated image. If the requested dimensions are closer to
>> my defaults then the image is ok, otherwise its blurred. How to get around
>> this?
>> Ideally I would like to create the image from start with the requested
>> dimensions then I need a way to figure out what appropriate fontsize and
>> stroke etc. to be used for various graphic objects within the image. Is
>> there a way?
>> Also how do we justify text (center, etc.) in an image?
>>
>> thanks.
>> [Message sent by forum member 'smp' (smp)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=232786
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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