Object c_Gmagick::t_writeimage(CStrRef filename, bool all_frames) { INSTANCE_METHOD_INJECTION_BUILTIN(Gmagick, Gmagick::writeimage); checkNotEmpty(); const char *c_filename; if (filename.isNull()) { c_filename = MagickGetImageFilename(magick_wand); if (!c_filename) { throwException("No image filename specified", FileOpenFatalError); } } else { c_filename = filename->data(); } int filename_len = strlen(c_filename); if (!filename_len) { throwException("Unable to write the image. Empty filename string provided", FileOpenFatalError); } int result; if (all_frames) { result = MagickWriteImage(magick_wand, c_filename); } else { result = MagickWriteImages(magick_wand, c_filename, MagickTrue); } checkResult(result); return this; }
String c_Gmagick::t_getimagefilename() { INSTANCE_METHOD_INJECTION_BUILTIN(Gmagick, Gmagick::getimagefilename); checkNotEmpty(); char *filename = MagickGetImageFilename(magick_wand); if (!filename) { return null; } return String(filename, strlen(filename), AttachString); }
int main(int argc, char *argv[]) { MagickWand *wand = NULL; MagickBooleanType ret; char *description; ExceptionType excep; if (argc < 2) { fprintf(stderr, "Usage: %s file\n", argv[0]); return 1; } MagickWandGenesis(); wand = NewMagickWand(); if (wand == NULL) { description = MagickGetException(wand, &excep); fprintf(stderr, "%s; %s\n", "NewMagickWand() failed", description); MagickRelinquishMemory(description); return 1; } ret = MagickReadImage(wand, argv[1]); if (ret != MagickTrue) { description = MagickGetException(wand, &excep); fprintf(stderr, "%s; %s\n", "MagickReadImage() failed", description); MagickRelinquishMemory(description); return 1; } printf("Format: %s\n", MagickGetImageFormat(wand)); printf("Filename: %s\n", MagickGetImageFilename(wand)); printf("Compression Quality: %ld\n", MagickGetCompressionQuality(wand)); printf("Signature: %s\n", MagickGetImageSignature(wand)); printf("Width: %ld\n", MagickGetImageWidth(wand)); printf("Height: %ld\n", MagickGetImageHeight(wand)); if (wand != NULL) { DestroyMagickWand(wand); } MagickWandTerminus(); return 0; }