Sign in Join
Wiki copytemporary

PascalMagick: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: PascalMagick

OldNewLine
1+### About
2+
3+#### About ImageMagick
4+
5+[ImageMagick](http://www.imagemagick.org) is a free software suite developed to create, edit, and compose bitmap images. It supports a huge variety of formats (over 200) including formats like GIF, JPEG, JPEG-2000, PNG, PDF, PhotoCD, TIFF, and DPX. Images can be cropped, colors can be changed, various effects can be applied, images can be rotated and combined, and text, lines, polygons, ellipses and Bézier curves can be added to images and stretched and rotated.
6+
7+The suite runs on all major operating systems and it can also be used from the command line and its command line tools package is one of Linux standard packages, being distributed with many distributions.
8+
9+Features and Capabilities:
10+
11+- Convert an image from one format to another (e.g. PNG to JPEG)
12+- Resize, rotate, sharpen, color reduce, or add special effects to an image
13+- Create a montage of image thumbnails
14+- Create a transparent image suitable for use on the Web
15+- Turn a group of images into a GIF animation sequence
16+- Create a composite image by combining several separate image
17+- Draw shapes or text on an image
18+- Decorate an image with a border or frame
19+- Describe the format and characteristics of an image
20+
21+#### ImageMagick Book
22+
23+[ImageMagick Tricks](http://www.packtpub.com/imagemagick/book) This fast paced and practical tutorial is packed with examples of photo manipulations, logo creation, animations, and complete web projects. With this book up your sleeve, you'll be creating spellbinding images from code in no time.
24+
25+#### About MagickWand
26+
27+The [MagickWand API](http://www.imagemagick.org/script/magick-wand.php) is the recommended interface by the ImageMagick team. It is an easy to use programming interface for using the suite.
28+
29+#### About MagickCore
30+
31+The MagickCore API is a low-level interface for ImageMagick.
32+
33+#### About PascalMagick
34+
35+This port is a translation of the c header files for both MagickWand and Magick Core.
36+
37+### Screenshot
38+
39+### Authors
40+
41+Felipe Monteiro de Carvalho
42+
43+Ángel Eduardo García
44+
45+### License
46+
47+BSD-style and compatible with the GPL.
48+
49+You can read the Licence [here](http://www.imagemagick.org/script/license.php).
50+
51+### Download
52+
53+> **Note:** PascalMagick is included in all recent FPC releases. There is no need to download it
54+
55+#### Old versions
56+
57+PascalMagick 0.4 is available here: <http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=174103&release_id=431432>
58+
59+For old FPC versions, you can download the subversion version of this project using this command:
60+
61+``` bash
62+svn checkout http://svn.freepascal.org/svn/fpc/trunk/packages/base/imagemagick imagemagick
63+```
64+
65+### Status
66+
67+Magick Wand headers are complete and working on both Windows and Linux.
68+
69+> **Warning:** MagickWand probably updated their headers in an incompatible way; current ImageMagick compressiontypes are incompatible with those in FPC \< 2.7.1; see [Issue \#26723](https://bugs.freepascal.org/view.php?id=26723) which also contains a workaround. This may apply to more ImageMagick consts, enums and function
70+
71+### Installation
72+
73+The current version of PascalMagick works on Windows and Linux. Beta testers are necessary for the Mac OS X version.
74+
75+To start with, install ImageMagick binaries from the official website: <http://www.imagemagick.org/script/binary-releases.php>
76+
77+— As the binaries version(s) there may have moved ahead of the current PascalMagick release, there is a 2022-07-13 discussion, on setup under Windows here: <https://forum.lazarus.freepascal.org/index.php?topic=59925.msg447403#msg447403>
78+
79+Now make sure the PascalMagick package is installed (Instructions on the #Download section above).
80+
81+To check that everything is working, open the packages\imagemagick\examples\wanddemo.lpr project under your FPC directory. Now go to the Project --\> "Compiler Options dialog" and change the "Other Units" field to point to "../magick", so it can find the PascalMagick/magick/ImageMagick.pas file. After this you can compile and run the test program.
82+
83+If the program is working, it will load the image.png image located on the same directory, resize it and then save it as a jpg called image.jpg.
84+
85+One extra step is necessary on Linux: Rename the image.PNG to image.png due to case issues.
86+
87+### Demonstration program 1
88+
89+``` pascal
90+{
91+ Demonstration program for the ImageMagick Library.
92+
93+ This program was converted from C by Felipe Monteiro de Carvalho.
94+
95+ Usage: Just execute the program. It will resize the image.png image
96+ on its directory to fit (106, 80) and convert it to a jpg.
97+
98+ Dez/2005
99+}
100+{Version 0.1}
101+program wanddemo;
102+
103+{$mode objfpc}{$H+}
104+
105+uses
106+ SysUtils, magick_wand, ImageMagick;
107+
108+procedure ThrowWandException(wand: PMagickWand);
109+var
110+ description: PChar;
111+ severity: ExceptionType;
112+begin
113+ description := MagickGetException(wand, @severity);
114+ WriteLn(Format('An error ocurred. Description: %s', [description]));
115+ description := MagickRelinquishMemory(description);
116+ Abort;
117+end;
118+
119+var
120+ status: MagickBooleanType;
121+ wand: PMagickWand;
122+begin
123+ { Read an image. }
124+
125+ MagickWandGenesis;
126+
127+ wand := NewMagickWand;
128+
129+ try
130+ status := MagickReadImage(wand, 'image.png');
131+ if (status = MagickFalse) then ThrowWandException(wand);
132+
133+ { Turn the images into a thumbnail sequence. }
134+
135+ MagickResetIterator(wand);
136+
137+ while (MagickNextImage(wand) <> MagickFalse) do
138+ MagickResizeImage(wand, 106, 80, LanczosFilter, 1.0);
139+
140+ { Write the image as MIFF and destroy it. }
141+
142+ status := MagickWriteImages(wand, 'image.jpg', MagickTrue);
143+ if (status = MagickFalse) then ThrowWandException(wand);
144+
145+ finally
146+ wand := DestroyMagickWand(wand);
147+
148+ MagickWandTerminus;
149+ end;
150+end.
151+```
152+
153+### Procedures to load images to a Lazarus TBitmap with ImageMagick
154+
155+Source: <http://lazarus.freepascal.org/index.php/topic,20016.msg114885.html#msg114885>
156+
157+``` pascal
158+unit magicklcl;
159+
160+{$mode objfpc}{$H+}
161+
162+interface
163+
164+uses
165+ Classes, SysUtils, Graphics;
166+
167+procedure LoadMagickBitmap(FileName: string; Bmp: TBitmap); overload;
168+procedure LoadMagickBitmap(Strm: TMemoryStream; Bmp: TBitmap); overload;
169+
170+implementation
171+
172+uses magick_wand, ImageMagick, IntfGraphics, FPimage, LazUTF8;
173+
174+procedure LoadMagickBitmapWand(Wand: PMagickWand; Bmp: TBitmap);
175+var
176+ img: Pimage;
177+ pack: PPixelPacket;
178+ limg: TLazIntfImage;
179+ i, j, wi, he: integer;
180+ colo: TFPColor;
181+begin
182+ img := GetImageFromMagickWand(wand);
183+ he := MagickGetImageHeight(wand);
184+ wi := MagickGetImageWidth(wand);
185+ limg := TLazIntfImage.Create(0, 0);
186+ try
187+ limg.DataDescription := GetDescriptionFromDevice(0, wi, he);
188+ pack := GetAuthenticPixels(img, 0, 0, wi, he, nil);
189+ for j := 0 to he - 1 do
190+ for i := 0 to wi - 1 do
191+ begin
192+ colo.red := pack^.red;
193+ colo.green := pack^.green;
194+ colo.blue := pack^.blue;
195+ colo.alpha := pack^.opacity;
196+ limg.Colors[i, j] := colo;
197+ Inc(pack);
198+ end;
199+ Bmp.LoadFromIntfImage(limg);
200+ finally
201+ limg.Free;
202+ end;
203+end;
204+
205+procedure LoadMagickBitmap(FileName: string; Bmp: TBitmap);
206+var
207+ wand: PMagickWand;
208+ status: MagickBooleanType;
209+ description: PChar;
210+ severity: ExceptionType;
211+begin
212+ wand := NewMagickWand;
213+ try
214+ status := MagickReadImage(wand, PChar(UTF8ToSys(FileName)));
215+ if (status = MagickFalse) then
216+ begin
217+ description := MagickGetException(wand, @severity);
218+ raise Exception.Create(Format('An error ocurred. Description: %s',
219+ [description]));
220+ description := MagickRelinquishMemory(description);
221+ end else LoadMagickBitmapWand(wand, Bmp);
222+ finally
223+ wand := DestroyMagickWand(wand);
224+ end;
225+end;
226+
227+procedure LoadMagickBitmap(Strm: TMemoryStream; Bmp: TBitmap);
228+var
229+ wand: PMagickWand;
230+ status: MagickBooleanType;
231+ description: PChar;
232+ severity: ExceptionType;
233+begin
234+ wand := NewMagickWand;
235+ try
236+ Strm.Position := 0;
237+ status := MagickReadImageBlob(wand, Strm.Memory, Strm.Size);
238+ if (status = MagickFalse) then
239+ begin
240+ description := MagickGetException(wand, @severity);
241+ raise Exception.Create(Format('An error ocurred. Description: %s',
242+ [description]));
243+ description := MagickRelinquishMemory(description);
244+ end else LoadMagickBitmapWand(wand, Bmp);
245+ finally
246+ wand := DestroyMagickWand(wand);
247+ end;
248+end;
249+
250+initialization
251+ MagickWandGenesis;
252+
253+finalization;
254+ MagickWandTerminus;
255+
256+end.
257+```
258+
259+### Bug Reporting/Feature Request
260+
261+Tests are necessary to verify if the bindings work with all versions of ImageMagick.
262+
263+Please post Bug Reports / Feature Requests in the discussion page.
264+
265+### Change Log
266+
267+- Later:
268+
269+1. Please see the fpc change log as the code has moved to the FPC source code.
270+
271+- 07.11.07
272+
273+1. Added 4 missing functions on magick_image.inc on fpc subversion, but no new release
274+
275+- 12.07.06 PascalMagick version 0.4 released
276+
277+1. Last bugs fixed
278+
279+- 24.05.06 PascalMagick version 0.3 released
280+
281+1. Minor fixes on the bindings
282+
283+- 10.04.06 PascalMagick version 0.2 released
284+
285+1. Based on ImageMagic 6.2
286+2. MagickWand API fully translated
287+3. Added a second demonstration program
288+
289+- 27.12.05 PascalMagick version 0.1 released
290+
291+1. About 80% of the MagickWand API is translated
292+2. The basic demonstration program is working well
293+3. Only the very minimum necessary MagickCode headers were translated
294+
295+- 14.12.05 Began working on a pascal port for the c headers
296+
297+### Help
298+
299+Please send help requests to the [[Forum|Lazarus Forum]] or the [Lazarus mailing list](https://lists.lazarus-ide.org/listinfo).
300+
301+---
302+*From the Free Pascal wiki, page "PascalMagick", as it stood on 2022-07-16 after a change by PaulANormanNZ, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
303+Category: Components
304+Category: Graphics
305+Category: Headers and Bindings

Back to history