* * *

Author Topic: Imagemagick. How use it?  (Read 1836 times)

Anton Shevtsov

  • New member
  • *
  • Posts: 10
Imagemagick. How use it?
« on: November 03, 2017, 05:02:15 am »
Hi


I found PascalMagick - http://wiki.freepascal.org/PascalMagick
But project is very old (11+ years old), and it is not working for me.
I want open png,tiff,bmp and convert to jpg. How i can do it?

Handoko

  • Hero Member
  • *****
  • Posts: 2610
  • My goal: build my own game engine using Lazarus
Re: Imagemagick. How use it?
« Reply #1 on: November 03, 2017, 05:47:11 am »
Maybe you can try fcl-image. I never tried Pascal Magick but I am able to do image resizing and converting using fcl-image:

http://wiki.freepascal.org/fcl-image

Anton Shevtsov

  • New member
  • *
  • Posts: 10
Re: Imagemagick. How use it?
« Reply #2 on: November 03, 2017, 06:00:43 am »
Thanks!

avra

  • Hero Member
  • *****
  • Posts: 1366
    • Additional info
Re: Imagemagick. How use it?
« Reply #3 on: November 03, 2017, 01:45:31 pm »
I found PascalMagick - http://wiki.freepascal.org/PascalMagick
But project is very old (11+ years old), and it is not working for me.
Did you install ImageMagick? Did you use PascalMagick found in FPC source?
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Anton Shevtsov

  • New member
  • *
  • Posts: 10
Re: Imagemagick. How use it?
« Reply #4 on: November 08, 2017, 11:24:13 am »
why pascalmagic, fclimage and other if i can make like as ? ))

Quote
procedure TForm1.ConvertToJPEG(Sender: TObject; FromFile: UTF8String; ToFile: UTF8String);
var
  pic: TPicture;
  jpg: TJPEGImage;
begin
  pic:=TPicture.Create;
  jpg:=TJPEGImage.Create;
  pic.LoadFromFile(FromFile);
  jpg.Assign(pic.Bitmap);
  jpg.CompressionQuality:=80;
  jpg.SaveToFile(ToFile);
  FreeAndNil(jpg);
  FreeAndNil(pic);
end;   



Handoko

  • Hero Member
  • *****
  • Posts: 2610
  • My goal: build my own game engine using Lazarus
Re: Imagemagick. How use it?
« Reply #5 on: November 08, 2017, 11:54:36 am »
You should not use the built-in image conversion feature. It had been discussed on this thread:
http://forum.lazarus.freepascal.org/index.php/topic,35313.msg256719.html#msg256719

The thread is very long. In short:
- The built-in image file loading often will crash with certain image files, especially tiff images.
- The better solution is to use fcl-image or TBGRABitmap

Anton Shevtsov

  • New member
  • *
  • Posts: 10
Re: Imagemagick. How use it?
« Reply #6 on: November 08, 2017, 12:09:05 pm »
Thanks.

[offtop]
how detect file format, like this
format := identifyFormat('/path/to/file.ext'); // jpeg, png, bmp
[/offtop]

Handoko

  • Hero Member
  • *****
  • Posts: 2610
  • My goal: build my own game engine using Lazarus
Re: Imagemagick. How use it?
« Reply #7 on: November 08, 2017, 12:15:02 pm »
Maybe not the best, but I will use ExtractFileExt:
https://www.freepascal.org/docs-html/rtl/sysutils/extractfileext.html

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus