You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Yegor Kozlov <ye...@dinom.ru> on 2007/10/01 20:33:55 UTC

[HSSF announce] Resizing images is implemented

Hi All,

The functionality to resize HSSF images to the actual width and height was requested many times. 
Finally it is implemented. HSSFPicture.resize() is a handy method to reset a picture to its original dimensions.

Usage:

    HSSFPatriarch patriarch = sheet.createDrawingPatriarch();

    HSSFPicture picture = patriarch.createPicture(new HSSFClientAnchor(), loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
    picture.resize();

or

    HSSFPatriarch patriarch = sheet.createDrawingPatriarch();

    HSSFPicture picture = patriarch.createPicture(new HSSFClientAnchor(), loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
    HSSFClientAnchor prefferedSize = picture.getPrefferedSize();
    picture.setAnchor(prefferedSize);

 
Note: HSSFPicture.resize() works only for PNG and JPEG. Other formats are not yet supported.


Regards,
Yegor Kozlov



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Re[2]: [HSSF announce] Resizing images is implemented

Posted by Christophe Charles <ch...@gmail.com>.
Ok Yegor !

I've use Eclipse with Subvision plugin; I've checkout the Trunk for source.

After that, I've build the jar distrib and got the 3 jar files...

I'am not testing this jars, but thanks for your job !

Regars

Chris

2007/10/15, Yegor Kozlov <ye...@dinom.ru>:
>
> I've updated the javadocs.
> Remember, to use HSSFPicture.resize() you need to download the latest
> build of POI from
> http://encore.torchbox.com/poi-svn-build/ (or build POI from SVN sources)
>
> Regards,
> Yegor
>
> > Hi Yegor,
>
> > I can't find the method : HSSFPicture.resize()  ?
>
> >
> http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFPicture.html#method_summary
>
> > Where cna i find it ?
>
> > Regards !
>
> > Chris
>
> > 2007/10/2, Christophe Charles <ch...@gmail.com>:
> >>
> >> I'm waiting with impatience for the next release !
> >>
> >> 2007/10/2, Christophe Charles <ch...@gmail.com>:
> >> >
> >> > Hi Yegor !
> >> >
> >> > I want to thank you for your big availability !
> >> >
> >> > Best regards !
> >> >
> >> > Chris
> >> >
> >> >
> >> >
> >> > 2007/10/1, Yegor Kozlov < yegor@dinom.ru >:
> >> > >
> >> > > Hi All,
> >> > >
> >> > > The functionality to resize HSSF images to the actual width and
> height
> >> > > was requested many times.
> >> > > Finally it is implemented. HSSFPicture.resize() is a handy method
> to
> >> > > reset a picture to its original dimensions.
> >> > >
> >> > > Usage:
> >> > >
> >> > >     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
> >> > >
> >> > >     HSSFPicture picture = patriarch.createPicture(new
> >> > > HSSFClientAnchor(), loadPicture(
> "src/resources/logos/logoKarmokar4.png", wb
> >> > > ));
> >> > >     picture.resize();
> >> > >
> >> > > or
> >> > >
> >> > >     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
> >> > >
> >> > >     HSSFPicture picture = patriarch.createPicture(new
> >> > > HSSFClientAnchor(), loadPicture(
> "src/resources/logos/logoKarmokar4.png", wb
> >> > > ));
> >> > >     HSSFClientAnchor prefferedSize = picture.getPrefferedSize();
> >> > >     picture.setAnchor(prefferedSize);
> >> > >
> >> > >
> >> > > Note: HSSFPicture.resize() works only for PNG and JPEG. Other
> formats
> >> > > are not yet supported.
> >> > >
> >> > >
> >> > > Regards,
> >> > > Yegor Kozlov
> >> > >
> >> > >
> >> > >
> >> > >
> ---------------------------------------------------------------------
> >> > > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> >> > > For additional commands, e-mail: user-help@poi.apache.org
> >> > >
> >> > >
> >> >
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re[2]: [HSSF announce] Resizing images is implemented

Posted by Yegor Kozlov <ye...@dinom.ru>.
I've updated the javadocs.
Remember, to use HSSFPicture.resize() you need to download the latest build of POI from
http://encore.torchbox.com/poi-svn-build/ (or build POI from SVN sources)

Regards,
Yegor

> Hi Yegor,

> I can't find the method : HSSFPicture.resize()  ?

> http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFPicture.html#method_summary

> Where cna i find it ?

> Regards !

> Chris

> 2007/10/2, Christophe Charles <ch...@gmail.com>:
>>
>> I'm waiting with impatience for the next release !
>>
>> 2007/10/2, Christophe Charles <ch...@gmail.com>:
>> >
>> > Hi Yegor !
>> >
>> > I want to thank you for your big availability !
>> >
>> > Best regards !
>> >
>> > Chris
>> >
>> >
>> >
>> > 2007/10/1, Yegor Kozlov < yegor@dinom.ru >:
>> > >
>> > > Hi All,
>> > >
>> > > The functionality to resize HSSF images to the actual width and height
>> > > was requested many times.
>> > > Finally it is implemented. HSSFPicture.resize() is a handy method to
>> > > reset a picture to its original dimensions.
>> > >
>> > > Usage:
>> > >
>> > >     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
>> > >
>> > >     HSSFPicture picture = patriarch.createPicture(new
>> > > HSSFClientAnchor(), loadPicture( "src/resources/logos/logoKarmokar4.png", wb
>> > > ));
>> > >     picture.resize();
>> > >
>> > > or
>> > >
>> > >     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
>> > >
>> > >     HSSFPicture picture = patriarch.createPicture(new
>> > > HSSFClientAnchor(), loadPicture( "src/resources/logos/logoKarmokar4.png", wb
>> > > ));
>> > >     HSSFClientAnchor prefferedSize = picture.getPrefferedSize();
>> > >     picture.setAnchor(prefferedSize);
>> > >
>> > >
>> > > Note: HSSFPicture.resize() works only for PNG and JPEG. Other formats
>> > > are not yet supported.
>> > >
>> > >
>> > > Regards,
>> > > Yegor Kozlov
>> > >
>> > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> > > For additional commands, e-mail: user-help@poi.apache.org
>> > >
>> > >
>> >
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re[2]: [HSSF announce] Resizing images is implemented

Posted by Yegor Kozlov <ye...@dinom.ru>.
Hi,

I forgot to update the java docs. Coming soon.

Yegor

> Hi Yegor,

> I can't find the method : HSSFPicture.resize()  ?

> http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFPicture.html#method_summary

> Where cna i find it ?

> Regards !

> Chris

> 2007/10/2, Christophe Charles <ch...@gmail.com>:
>>
>> I'm waiting with impatience for the next release !
>>
>> 2007/10/2, Christophe Charles <ch...@gmail.com>:
>> >
>> > Hi Yegor !
>> >
>> > I want to thank you for your big availability !
>> >
>> > Best regards !
>> >
>> > Chris
>> >
>> >
>> >
>> > 2007/10/1, Yegor Kozlov < yegor@dinom.ru >:
>> > >
>> > > Hi All,
>> > >
>> > > The functionality to resize HSSF images to the actual width and height
>> > > was requested many times.
>> > > Finally it is implemented. HSSFPicture.resize() is a handy method to
>> > > reset a picture to its original dimensions.
>> > >
>> > > Usage:
>> > >
>> > >     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
>> > >
>> > >     HSSFPicture picture = patriarch.createPicture(new
>> > > HSSFClientAnchor(), loadPicture( "src/resources/logos/logoKarmokar4.png", wb
>> > > ));
>> > >     picture.resize();
>> > >
>> > > or
>> > >
>> > >     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
>> > >
>> > >     HSSFPicture picture = patriarch.createPicture(new
>> > > HSSFClientAnchor(), loadPicture( "src/resources/logos/logoKarmokar4.png", wb
>> > > ));
>> > >     HSSFClientAnchor prefferedSize = picture.getPrefferedSize();
>> > >     picture.setAnchor(prefferedSize);
>> > >
>> > >
>> > > Note: HSSFPicture.resize() works only for PNG and JPEG. Other formats
>> > > are not yet supported.
>> > >
>> > >
>> > > Regards,
>> > > Yegor Kozlov
>> > >
>> > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> > > For additional commands, e-mail: user-help@poi.apache.org
>> > >
>> > >
>> >
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: [HSSF announce] Resizing images is implemented

Posted by Christophe Charles <ch...@gmail.com>.
Hi Yegor,

I can't find the method : HSSFPicture.resize()  ?

http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFPicture.html#method_summary

Where cna i find it ?

Regards !

Chris

2007/10/2, Christophe Charles <ch...@gmail.com>:
>
> I'm waiting with impatience for the next release !
>
> 2007/10/2, Christophe Charles <ch...@gmail.com>:
> >
> > Hi Yegor !
> >
> > I want to thank you for your big availability !
> >
> > Best regards !
> >
> > Chris
> >
> >
> >
> > 2007/10/1, Yegor Kozlov < yegor@dinom.ru >:
> > >
> > > Hi All,
> > >
> > > The functionality to resize HSSF images to the actual width and height
> > > was requested many times.
> > > Finally it is implemented. HSSFPicture.resize() is a handy method to
> > > reset a picture to its original dimensions.
> > >
> > > Usage:
> > >
> > >     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
> > >
> > >     HSSFPicture picture = patriarch.createPicture(new
> > > HSSFClientAnchor(), loadPicture( "src/resources/logos/logoKarmokar4.png", wb
> > > ));
> > >     picture.resize();
> > >
> > > or
> > >
> > >     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
> > >
> > >     HSSFPicture picture = patriarch.createPicture(new
> > > HSSFClientAnchor(), loadPicture( "src/resources/logos/logoKarmokar4.png", wb
> > > ));
> > >     HSSFClientAnchor prefferedSize = picture.getPrefferedSize();
> > >     picture.setAnchor(prefferedSize);
> > >
> > >
> > > Note: HSSFPicture.resize() works only for PNG and JPEG. Other formats
> > > are not yet supported.
> > >
> > >
> > > Regards,
> > > Yegor Kozlov
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> > > For additional commands, e-mail: user-help@poi.apache.org
> > >
> > >
> >
>

Re: [HSSF announce] Resizing images is implemented

Posted by Christophe Charles <ch...@gmail.com>.
I'm waiting with impatience for the next release !

2007/10/2, Christophe Charles <ch...@gmail.com>:
>
> Hi Yegor !
>
> I want to thank you for your big availability !
>
> Best regards !
>
> Chris
>
>
>
> 2007/10/1, Yegor Kozlov <yegor@dinom.ru >:
> >
> > Hi All,
> >
> > The functionality to resize HSSF images to the actual width and height
> > was requested many times.
> > Finally it is implemented. HSSFPicture.resize() is a handy method to
> > reset a picture to its original dimensions.
> >
> > Usage:
> >
> >     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
> >
> >     HSSFPicture picture = patriarch.createPicture(new
> > HSSFClientAnchor(), loadPicture( "src/resources/logos/logoKarmokar4.png", wb
> > ));
> >     picture.resize();
> >
> > or
> >
> >     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
> >
> >     HSSFPicture picture = patriarch.createPicture(new
> > HSSFClientAnchor(), loadPicture( "src/resources/logos/logoKarmokar4.png", wb
> > ));
> >     HSSFClientAnchor prefferedSize = picture.getPrefferedSize();
> >     picture.setAnchor(prefferedSize);
> >
> >
> > Note: HSSFPicture.resize() works only for PNG and JPEG. Other formats
> > are not yet supported.
> >
> >
> > Regards,
> > Yegor Kozlov
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> > For additional commands, e-mail: user-help@poi.apache.org
> >
> >
>

Re: [HSSF announce] Resizing images is implemented

Posted by Christophe Charles <ch...@gmail.com>.
Hi Yegor !

I want to thank you for your big availability !

Best regards !

Chris



2007/10/1, Yegor Kozlov <ye...@dinom.ru>:
>
> Hi All,
>
> The functionality to resize HSSF images to the actual width and height was
> requested many times.
> Finally it is implemented. HSSFPicture.resize() is a handy method to reset
> a picture to its original dimensions.
>
> Usage:
>
>     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
>
>     HSSFPicture picture = patriarch.createPicture(new HSSFClientAnchor(),
> loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
>     picture.resize();
>
> or
>
>     HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
>
>     HSSFPicture picture = patriarch.createPicture(new HSSFClientAnchor(),
> loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
>     HSSFClientAnchor prefferedSize = picture.getPrefferedSize();
>     picture.setAnchor(prefferedSize);
>
>
> Note: HSSFPicture.resize() works only for PNG and JPEG. Other formats are
> not yet supported.
>
>
> Regards,
> Yegor Kozlov
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

RE: [HSSF announce] Resizing images is implemented

Posted by Geoff Groskreutz <gr...@versifit.com>.
Yegor,

I have tested this resize functionality with the POI V3.0.2 beta 1 release,
and found that it works fine, until you change the width of any column or
the height of any row that the image will be anchored to.  Even if I call
the resize method after the column widths and row heights have been set, the
function does not seem to take into account these size changes in the
underlying columns and rows before it determines what rows and columns to
anchor it to. (I believe I am correct in assuming that the XLS format does
not allow absolute positioning and sizing of images, but instead everything
must be anchored to a cell(s)...what a pain, but anyway...)

However, since I need to change the size of columns and rows, this resize
method (I also tried the getPreferredSize method, which I am guessing is
called by the resize method) will not work, so instead I just hacked a
routine together, after I perform all necessary column and row sizing it
then finds the correct end cell to anchor the image to and then determines
the end point inside this last cell(I assume this is some percentage of the
available cell width with 1023 as max value). It also looks to me that this
is the same type of routine that you used in the resize functionality, but
it seems to only use the default row and column sizes and not their current
values.

Currently, for the "hacked" routine I have in-place for determining the
correct anchor positions, I need to know the image's actual width and height
in pixels, and I perform the proper conversions as necessary, however, the
conversion to calculate the actual width of the image for use in the column
width assignment was not intuitive (I basically had to use trial and error
to get the right conversion multiplier), since I can't quite determine what
unit of measurement is being used when setting the width of a column.

So, I guess if you wouldn't mind looking into this, it would be great.

Also, it would be great, if available, to expose (for read only) the actual
height and width (in pixels, twips, or both) of the image being loaded and
created, preferably in the HSSFPicture object itself.

Thanks,

Geoff Groskreutz
-----Original Message-----
From: Yegor Kozlov [mailto:yegor@dinom.ru] 
Sent: Monday, October 01, 2007 1:34 PM
To: POI Users List
Subject: [HSSF announce] Resizing images is implemented

Hi All,

The functionality to resize HSSF images to the actual width and height was
requested many times. 
Finally it is implemented. HSSFPicture.resize() is a handy method to reset a
picture to its original dimensions.

Usage:

    HSSFPatriarch patriarch = sheet.createDrawingPatriarch();

    HSSFPicture picture = patriarch.createPicture(new HSSFClientAnchor(),
loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
    picture.resize();

or

    HSSFPatriarch patriarch = sheet.createDrawingPatriarch();

    HSSFPicture picture = patriarch.createPicture(new HSSFClientAnchor(),
loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
    HSSFClientAnchor prefferedSize = picture.getPrefferedSize();
    picture.setAnchor(prefferedSize);

 
Note: HSSFPicture.resize() works only for PNG and JPEG. Other formats are
not yet supported.


Regards,
Yegor Kozlov



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org