Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-08

TJPegImage on CGI app

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Leonardo M. Ramé

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.

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

Reply by email

Michael Van Canneyt
to Leonardo M. Ramé
Leonardo M. Ram? wrote 19 lines
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.

Reply by email

Leonardo M. Ramé
to Michael Van Canneyt

El mar, 31-08-2010 a las 19:21 +0200, Michael Van Canneyt escribi?:

Show quoted text 46 lines
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

Reply by email