[Lazarus] TJPegImage on CGI app

Leonardo M. Ramé l.rame at griensu.com
Tue Aug 31 19:52:20 CEST 2010


El mar, 31-08-2010 a las 19:21 +0200, Michael Van Canneyt escribió:
> 
> On Tue, 31 Aug 2010, Leonardo M. Ramé wrote:
> 
> > Hi, I need to get width and height of a JPeg file from a CGI app, and it
> > allways return 0 for both properties. If I test the same function on a
> > GTK2 or Win32 application, the values are returned correctly. Is this a
> > bug?.
> >
> > function getWidth: Integer;
> > var
> >   lJpeg: TJPEGImage;
> > begin
> >   lJpeg := TJPEGImage.Create;
> >   try
> >     lJpeg.LoadFromFile('myimage.jpg');
> >     Result := lJpeg.Width;
> >   finally
> >     lJpeg.Free;
> >   end;
> > end;
> >
> > I'm using Lazarus and FPC from Trunk in Ubuntu 10.04 64bits.
> 
> Don't use TJPEgImage;
> 
> This is a visual component and relies on the LCL, which is not available in CGI apps.
> 
> Use TFPMemoryImage of the fpimage unit instead:
> 
> function getWidth: Integer;
> var
>    lJpeg: TFPMemoryImage;
> 
> begin
>    lJpeg := TFPMemoryImage.Create;
>    try
>      lJpeg.LoadFromFile('myimage.jpg');
>      Result := lJpeg.Width;
>    finally
>      lJpeg.Free;
>    end;
> end;
> 
> Make sure that fpreadjpg is included in your uses clause, so jpeg format can be read.
> 
> Michael.

Thanks Michael, much better now.

-- 
Leonardo M. Ramé
Griensu S.A. - Medical IT Córdoba
Tel.: 0351-4247979





More information about the Lazarus mailing list