1 // Copyright (C) GraphicsMagick Group 2002 - 2022
2 import core
.stdc
.stdio
;
4 import graphicsmagick_c
.config
;
5 import graphicsmagick_c
.wand
.wand_api
;
7 extern (C
) int main(int argc
, char** argv
)
9 MagickWand
* magick_wand
;
10 MagickPassFail status
= MagickPass
;
12 char* infile
, outfile
;
15 fprintf(stderr
, "Usage: %s infile outfile\n", argv
[0]);
22 // Load dynamic bindings if required
23 version (GMagick_Static
) {}
28 bool success
= loadGraphicsMagick(libgm
);
30 puts("Successfully loaded GraphicsMagick!\n");
32 puts("Loaded GraphicsMagick with some errors!\n");
35 success
= loadGraphicsMagickWand(libgmwand
);
37 puts("Successfully loaded GraphicsMagickWand!\n");
39 puts("Loaded GraphicsMagikcWand with some errors!\n");
43 // Initialize GraphicsMagick API
44 InitializeMagick(*argv
);
46 // Allocate Wand handle
47 magick_wand
= NewMagickWand();
49 // Read input image file
50 if (status
== MagickPass
) {
51 status
= MagickReadImage(magick_wand
, infile
);
54 // Rotate the image clockwise 30 degrees with a black background
55 if (status
== MagickPass
) {
56 PixelWand
* background
;
57 background
= NewPixelWand();
58 PixelSetColor(background
, "#000000");
59 status
= MagickRotateImage(magick_wand
, background
, 30);
60 DestroyPixelWand(background
);
64 if (status
== MagickPass
) {
65 status
= MagickWriteImage(magick_wand
, outfile
);
69 if (status
!= MagickPass
) {
71 ExceptionType severity
;
73 description
= MagickGetException(magick_wand
, &severity
);
74 fprintf(stderr
, "%.1024s (severity %d)\n", description
, severity
);
77 // Release Wand handle
78 DestroyMagickWand(magick_wand
);
80 // Destroy GraphicsMagick API
83 return (status
== MagickPass ?
0 : 1);