77 bool indexed = (img.classType () == Magick::PseudoClass);
82 const std::string fmt = img.magick ();
87 else if (fmt ==
"PNG")
96 const std::string color_type =
97 const_cast<Magick::Image&
> (img).attribute (
"PNG:IHDR.color-type-orig");
98 if (! color_type.empty() && color_type !=
"3")
125 && img.channelDepth (Magick::RedChannel) == 1
126 && img.channelDepth (Magick::CyanChannel) == 1
127 && img.channelDepth (Magick::OpacityChannel) == 1
128 && img.channelDepth (Magick::GrayChannel) == 1)
147 output =
Range (value, value);
150 error (
"__magick_read__: unknow datatype for Region option");
155 static std::map<std::string, octave_idx_type>
158 std::map<std::string, octave_idx_type> region;
164 region[
"row_start"] = rows.
base () -1;
165 region[
"col_start"] = cols.
base () -1;
166 region[
"row_end"] = rows.
max () -1;
167 region[
"col_end"] = cols.
max () -1;
171 region[
"row_cache"] = region[
"row_end"] - region[
"row_start"] +1;
172 region[
"col_cache"] = region[
"col_end"] - region[
"col_start"] +1;
175 region[
"row_shift"] = region[
"col_cache"] * rows.
inc ();
176 region[
"col_shift"] = region[
"col_cache"] *
177 (region[
"row_cache"] + rows.
inc () -1) - cols.
inc ();
180 region[
"row_out"] = rows.
nelem ();
181 region[
"col_out"] = cols.
nelem ();
195 const Magick::ColorRGB c = img.colorMap (i);
196 cmap(i,0) = c.red ();
197 cmap(i,1) = c.green ();
198 cmap(i,2) = c.blue ();
199 amap(i) = c.alpha ();
214 typedef typename T::element_type P;
228 T img = T (
dim_vector (nRows, nCols, 1, nFrames));
229 P* img_fvec = img.fortran_vec ();
245 imvec[frameidx(frame)].getConstPixels (col_start, row_start,
246 col_cache, row_cache);
248 const Magick::IndexPacket *pix
249 = imvec[frameidx(frame)].getConstIndexes ();
255 img_fvec[idx++] =
static_cast<P
> (*pix);
272 read_maps (const_cast<Magick::Image&> (imvec[frameidx(def_elem)]));
277 if (imvec[def_elem].matte () && nargout >= 3)
279 const Matrix amap = maps(1).matrix_value ();
289 alpha_fvec[pix] = 1 - amap_fvec[static_cast<int> (img_fvec[3])];
309 typedef typename T::element_type P;
350 if (imvec[def_elem].depth () == 32)
353 divisor = MaxRGB / ((uint64_t (1) << imvec[def_elem].depth ()) - 1);
362 Magick::ImageType
type = imvec[def_elem].type ();
363 if (type == Magick::BilevelType && imvec[def_elem].matte ())
364 type = Magick::GrayscaleMatteType;
373 if (imvec[0].magick () ==
"PNG")
383 const std::string type_str
384 = imvec[0].attribute (
"PNG:IHDR.color-type-orig");
387 type = Magick::GrayscaleType;
388 else if (type_str ==
"2")
389 type = Magick::TrueColorType;
390 else if (type_str ==
"6")
391 type = Magick::TrueColorMatteType;
392 else if (type_str ==
"4")
393 type = Magick::GrayscaleMatteType;
399 if (imvec[0].matte ())
401 if (type == Magick::GrayscaleType)
402 type = Magick::GrayscaleMatteType;
403 else if (type == Magick::TrueColorType)
404 type = Magick::TrueColorMatteType;
414 case Magick::GrayscaleMatteType:
415 type = Magick::GrayscaleType;
418 case Magick::PaletteMatteType:
419 type = Magick::PaletteType;
422 case Magick::TrueColorMatteType:
423 type = Magick::TrueColorType;
426 case Magick::ColorSeparationMatteType:
427 type = Magick::ColorSeparationType;
440 case Magick::BilevelType:
441 case Magick::GrayscaleType:
443 img = T (
dim_vector (nRows, nCols, 1, nFrames));
444 P *img_fvec = img.fortran_vec ();
450 const Magick::PixelPacket *pix
451 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
452 col_cache, row_cache);
458 img_fvec[idx++] = pix->red / divisor;
467 case Magick::GrayscaleMatteType:
469 img = T (
dim_vector (nRows, nCols, 1, nFrames));
470 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
471 P *img_fvec = img.fortran_vec ();
472 P *a_fvec = alpha.fortran_vec ();
478 const Magick::PixelPacket *pix
479 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
480 col_cache, row_cache);
486 img_fvec[idx] = pix->red / divisor;
487 a_fvec[idx] = (MaxRGB - pix->opacity) / divisor;
498 case Magick::PaletteType:
499 case Magick::TrueColorType:
501 img = T (
dim_vector (nRows, nCols, 3, nFrames));
502 P *img_fvec = img.fortran_vec ();
508 const Magick::PixelPacket *pix
509 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
510 col_cache, row_cache);
514 P *gbuf = img_fvec + colour_stride;
515 P *bbuf = img_fvec + colour_stride * 2;
521 rbuf[idx] = pix->red / divisor;
522 gbuf[idx] = pix->green / divisor;
523 bbuf[idx] = pix->blue / divisor;
529 img_fvec += frame_stride;
534 case Magick::PaletteMatteType:
535 case Magick::TrueColorMatteType:
537 img = T (
dim_vector (nRows, nCols, 3, nFrames));
538 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
539 P *img_fvec = img.fortran_vec ();
540 P *a_fvec = alpha.fortran_vec ();
550 const Magick::PixelPacket *pix
551 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
552 col_cache, row_cache);
556 P *gbuf = img_fvec + colour_stride;
557 P *bbuf = img_fvec + colour_stride * 2;
563 rbuf[idx] = pix->red / divisor;
564 gbuf[idx] = pix->green / divisor;
565 bbuf[idx] = pix->blue / divisor;
566 a_fvec[a_idx++] = (MaxRGB - pix->opacity) / divisor;
572 img_fvec += frame_stride;
578 case Magick::ColorSeparationType:
580 img = T (
dim_vector (nRows, nCols, 4, nFrames));
581 P *img_fvec = img.fortran_vec ();
587 const Magick::PixelPacket *pix
588 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
589 col_cache, row_cache);
593 P *mbuf = img_fvec + colour_stride;
594 P *ybuf = img_fvec + colour_stride * 2;
595 P *kbuf = img_fvec + colour_stride * 3;
601 cbuf[idx] = pix->red / divisor;
602 mbuf[idx] = pix->green / divisor;
603 ybuf[idx] = pix->blue / divisor;
604 kbuf[idx] = pix->opacity / divisor;
610 img_fvec += frame_stride;
616 case Magick::ColorSeparationMatteType:
618 img = T (
dim_vector (nRows, nCols, 4, nFrames));
619 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
620 P *img_fvec = img.fortran_vec ();
621 P *a_fvec = alpha.fortran_vec ();
631 const Magick::PixelPacket *pix
632 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
633 col_cache, row_cache);
636 const Magick::IndexPacket *apix
637 = imvec[frameidx(frame)].getConstIndexes ();
641 P *mbuf = img_fvec + colour_stride;
642 P *ybuf = img_fvec + colour_stride * 2;
643 P *kbuf = img_fvec + colour_stride * 3;
649 cbuf[idx] = pix->red / divisor;
650 mbuf[idx] = pix->green / divisor;
651 ybuf[idx] = pix->blue / divisor;
652 kbuf[idx] = pix->opacity / divisor;
653 a_fvec[a_idx++] = (MaxRGB - *apix) / divisor;
659 img_fvec += frame_stride;
666 error (
"__magick_read__: unknown Magick++ image type");
676 read_file (
const std::string& filename, std::vector<Magick::Image>& imvec)
680 Magick::readImages (&imvec, filename);
682 catch (Magick::Warning&
w)
684 warning (
"Magick++ warning: %s", w.what ());
686 catch (Magick::Exception& e)
688 error (
"Magick++ exception: %s", e.what ());
696 static bool initialized =
false;
702 const char *static_locale = setlocale (LC_ALL, NULL);
703 const std::string locale (static_locale);
705 const std::string program_name
707 Magick::InitializeMagick (program_name.c_str ());
710 setlocale (LC_ALL, locale.c_str ());
712 if (QuantumDepth < 32)
714 "your version of %s limits images to %d bits per pixel",
715 MagickPackageName, QuantumDepth);
722 DEFUN_DLD (__magick_read__, args, nargout,
724 @deftypefn {Loadable Function} {[@var{img}, @var{map}, @var{alpha}] =} __magick_read__ (@var{fname}, @var{options})\n\
725 Read image with GraphicsMagick or ImageMagick.\n\
727 This is a private internal function not intended for direct use.\n\
728 Use @code{imread} instead.\n\
730 @seealso{imfinfo, imformats, imread, imwrite}\n\
741 if (args.length () != 2 || ! args(0).is_string ())
750 error (
"__magick_read__: OPTIONS must be a struct");
754 std::vector<Magick::Image> imvec;
755 read_file (args(0).string_value (), imvec);
774 error (
"__magick_read__: invalid value for Index/Frame");
783 if (frameidx(i) < 0 || frameidx(i) > nFrames - 1)
788 error (
"imread: index/frames specified are outside the number of images");
799 const unsigned int nRows = imvec[frameidx(0)].rows ();
800 const unsigned int nCols = imvec[frameidx(0)].columns ();
804 if (nRows != imvec[frameidx(frame)].rows ()
805 || nCols != imvec[frameidx(frame)].columns ())
807 error (
"imread: all frames must have the same size but frame %i is different",
818 output = read_indexed_images<boolNDArray> (imvec, frameidx,
821 output = read_indexed_images<uint8NDArray> (imvec, frameidx,
823 else if (depth <= 16)
824 output = read_indexed_images<uint16NDArray> (imvec, frameidx,
828 error (
"imread: indexed images with depths greater than 16-bit are not supported");
836 output = read_images<boolNDArray> (imvec, frameidx, nargout, options);
838 output = read_images<uint8NDArray> (imvec, frameidx, nargout, options);
839 else if (depth <= 16)
840 output = read_images<uint16NDArray> (imvec, frameidx, nargout, options);
841 else if (depth <= 32)
842 output = read_images<FloatNDArray> (imvec, frameidx, nargout, options);
845 error (
"imread: reading of images with %i-bit depth is not supported",
865 typedef typename T::element_type P;
869 const P* img_fvec = img.fortran_vec ();
874 out_fvec[idx] = img_fvec[idx] * max;
885 typedef typename T::element_type P;
887 sizeof (P) * std::numeric_limits<unsigned char>::digits;
894 const Magick::ImageType&
type,
895 const Magick::ClassType& klass)
897 Magick::Image img (Magick::Geometry (nCols, nRows),
"black");
901 img.classType (klass);
905 img.depth (bitdepth);
908 case Magick::GrayscaleMatteType:
909 case Magick::TrueColorMatteType:
910 case Magick::ColorSeparationMatteType:
911 case Magick::PaletteMatteType:
928 typedef typename T::element_type P;
937 std::vector<Magick::ColorRGB> colormap;
943 colormap.push_back (Magick::ColorRGB (cmap_fvec[map_idx],
944 cmap_fvec[map_idx + G_offset],
945 cmap_fvec[map_idx + B_offset]));
953 Magick::PseudoClass);
956 m_img.colorMapSize (cmap_size);
958 m_img.colorMap (map_idx, colormap[map_idx]);
969 Magick::PixelPacket* pix = m_img.getPixels (0, 0, nCols, nRows);
970 Magick::IndexPacket* ind = m_img.getIndexes ();
971 const P* img_fvec = img.fortran_vec ();
978 ind[GM_idx] =
double (*img_fvec);
979 pix[GM_idx] = m_img.colorMap (
double (*img_fvec));
983 GM_idx -= nCols * nRows - 1;
988 imvec.push_back (m_img);
1000 const Magick::Color white (
"white");
1012 Magick::GrayscaleType,
1013 Magick::DirectClass);
1015 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1021 if (img_fvec[img_idx])
1022 pix[GM_idx] = white;
1027 GM_idx -= nCols * nRows - 1;
1030 m_img.syncPixels ();
1033 m_img.type (Magick::BilevelType);
1034 imvec.push_back (m_img);
1041 const T& img,
const T& alpha)
1043 typedef typename T::element_type P;
1044 const octave_idx_type channels = img.ndims () < 3 ? 1 : img.dims ()(2);
1045 const octave_idx_type nFrames = img.ndims () < 4 ? 1 : img.dims ()(3);
1050 Magick::ImageType
type;
1051 const bool has_alpha = ! alpha.is_empty ();
1056 type = Magick::GrayscaleMatteType;
1058 type = Magick::GrayscaleType;
1063 type = Magick::TrueColorMatteType;
1065 type = Magick::TrueColorType;
1070 type = Magick::ColorSeparationMatteType;
1072 type = Magick::ColorSeparationType;
1078 error (
"__magick_write__: wrong size on 3rd dimension");
1090 const double divisor =
static_cast<double>((uint64_t (1) << bitdepth) - 1)
1093 const P *img_fvec = img.fortran_vec ();
1094 const P *a_fvec = alpha.fortran_vec ();
1097 case Magick::GrayscaleType:
1104 Magick::DirectClass);
1106 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1112 const double grey =
double (*img_fvec) / divisor;
1113 Magick::Color c (grey, grey, grey);
1118 GM_idx -= nCols * nRows - 1;
1121 m_img.syncPixels ();
1122 imvec.push_back (m_img);
1127 case Magick::GrayscaleMatteType:
1134 Magick::DirectClass);
1136 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1142 double grey =
double (*img_fvec) / divisor;
1143 Magick::Color c (grey, grey, grey,
1144 MaxRGB - (
double (*a_fvec) / divisor));
1150 GM_idx -= nCols * nRows - 1;
1153 m_img.syncPixels ();
1154 imvec.push_back (m_img);
1159 case Magick::TrueColorType:
1169 Magick::DirectClass);
1171 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1177 Magick::Color c (
double (*img_fvec) / divisor,
1178 double (img_fvec[G_offset]) / divisor,
1179 double (img_fvec[B_offset]) / divisor);
1184 GM_idx -= nCols * nRows - 1;
1187 m_img.syncPixels ();
1188 imvec.push_back (m_img);
1189 img_fvec += B_offset;
1194 case Magick::TrueColorMatteType:
1204 Magick::DirectClass);
1206 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1212 Magick::Color c (
double (*img_fvec) / divisor,
1213 double (img_fvec[G_offset]) / divisor,
1214 double (img_fvec[B_offset]) / divisor,
1215 MaxRGB - (
double (*a_fvec) / divisor));
1221 GM_idx -= nCols * nRows - 1;
1224 m_img.syncPixels ();
1225 imvec.push_back (m_img);
1226 img_fvec += B_offset;
1231 case Magick::ColorSeparationType:
1242 Magick::DirectClass);
1244 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1250 Magick::Color c (
double (*img_fvec) / divisor,
1251 double (img_fvec[M_offset]) / divisor,
1252 double (img_fvec[Y_offset]) / divisor,
1253 double (img_fvec[K_offset]) / divisor);
1258 GM_idx -= nCols * nRows - 1;
1261 m_img.syncPixels ();
1262 imvec.push_back (m_img);
1263 img_fvec += K_offset;
1268 case Magick::ColorSeparationMatteType:
1279 Magick::DirectClass);
1281 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1282 Magick::IndexPacket *ind = m_img.getIndexes ();
1288 Magick::Color c (
double (*img_fvec) / divisor,
1289 double (img_fvec[M_offset]) / divisor,
1290 double (img_fvec[Y_offset]) / divisor,
1291 double (img_fvec[K_offset]) / divisor);
1293 ind[GM_idx] = MaxRGB - (
double (*a_fvec) / divisor);
1298 GM_idx -= nCols * nRows - 1;
1301 m_img.syncPixels ();
1302 imvec.push_back (m_img);
1303 img_fvec += K_offset;
1310 error (
"__magick_write__: unrecognized Magick::ImageType");
1318 static std::map<octave_idx_type, std::string>
1336 static std::map<octave_idx_type, std::string> methods;
1337 if (methods.empty ())
1339 methods[0] =
"doNotSpecify";
1340 methods[1] =
"leaveInPlace";
1341 methods[2] =
"restoreBG";
1342 methods[3] =
"restorePrevious";
1346 static std::map<std::string, octave_idx_type>
1349 static std::map<std::string, octave_idx_type> methods;
1350 if (methods.empty ())
1352 methods[
"donotspecify"] = 0;
1353 methods[
"leaveinplace"] = 1;
1354 methods[
"restorebg"] = 2;
1355 methods[
"restoreprevious"] = 3;
1362 const std::string& ext,
1363 std::vector<Magick::Image>& imvec)
1367 Magick::writeImages (imvec.begin (), imvec.end (), ext +
":" + filename);
1369 catch (Magick::Warning&
w)
1371 warning (
"Magick++ warning: %s", w.what ());
1373 catch (Magick::ErrorCoder& e)
1375 warning (
"Magick++ coder error: %s", e.what ());
1377 catch (Magick::Exception& e)
1379 error (
"Magick++ exception: %s", e.what ());
1388 @deftypefn {Loadable Function} {} __magick_write__ (@var{fname}, @var{fmt}, @var{img}, @var{map}, @var{options})\n\
1389 Write image with GraphicsMagick or ImageMagick.\n\
1391 This is a private internal function not intended for direct use.\n\
1392 Use @code{imwrite} instead.\n\
1394 @seealso{imfinfo, imformats, imread, imwrite}\n\
1405 if (args.length () != 5 || ! args(0).is_string () || ! args(1).is_string ())
1410 const std::string filename = args(0).string_value ();
1411 const std::string ext = args(1).string_value ();
1416 error (
"__magick_write__: OPTIONS must be a struct");
1421 const Matrix cmap = args(3).matrix_value ();
1424 error (
"__magick_write__: invalid IMG or MAP");
1428 std::vector<Magick::Image> imvec;
1455 clip_img = img_float2uint<FloatNDArray>
1457 clip_alpha = img_float2uint<FloatNDArray>
1462 clip_img = img_float2uint<NDArray> (img.
array_value ());
1463 clip_alpha = img_float2uint<NDArray> (alpha.
array_value ());
1465 encode_uint_image<uint32NDArray> (imvec, clip_img, clip_alpha);
1469 error (
"__magick_write__: image type not supported");
1486 error (
"__magick_write__: indexed image must be uint8, uint16 or float.");
1490 static std::map<std::string, octave_idx_type> disposal_methods
1502 imvec[i].quality (quality);
1503 imvec[i].animationDelay (delaytime(i));
1504 imvec[i].gifDisposeMethod (disposal_methods[disposalmethod(i)]);
1510 if (writemode ==
"append" &&
file_stat (filename).exists ())
1512 std::vector<Magick::Image> ini_imvec;
1516 if (ini_imvec.size () > 0)
1518 ini_imvec.insert (ini_imvec.end (), imvec.begin (), imvec.end ());
1519 ini_imvec.swap (imvec);
1568 @deftypefn {Loadable Function} {} __magick_ping__ (@var{fname}, @var{idx})\n\
1569 Ping image information with GraphicsMagick or ImageMagick.\n\
1571 This is a private internal function not intended for direct use.\n\
1573 @seealso{imfinfo}\n\
1582 if (args.length () < 1 || ! args(0).is_string ())
1589 if (args.length () > 1)
1590 idx = args(1).int_value () -1;
1599 img.ping (filename);
1601 catch (Magick::Warning&
w)
1603 warning (
"Magick++ warning: %s", w.what ());
1605 catch (Magick::Exception& e)
1607 error (
"Magick++ exception: %s", e.what ());
1611 static const char *fields[] = {
"rows",
"columns",
"format", 0};
1627 case Magick::NoCompression:
1629 case Magick::BZipCompression:
1631 case Magick::FaxCompression:
1633 case Magick::Group4Compression:
1635 case Magick::JPEGCompression:
1637 case Magick::LZWCompression:
1639 case Magick::RLECompression:
1643 case Magick::ZipCompression:
1670 case Magick::LSBEndian:
1672 case Magick::MSBEndian:
1685 case Magick::TopLeftOrientation:
1687 case Magick::TopRightOrientation:
1689 case Magick::BottomRightOrientation:
1691 case Magick::BottomLeftOrientation:
1693 case Magick::LeftTopOrientation:
1695 case Magick::RightTopOrientation:
1697 case Magick::RightBottomOrientation:
1699 case Magick::LeftBottomOrientation:
1711 case Magick::PixelsPerInchResolution:
1713 case Magick::PixelsPerCentimeterResolution:
1725 return (! val.empty () && val !=
"unknown");
1730 const std::string& key)
1732 const std::string attr = img.attribute (
"EXIF:" + key);
1740 const std::string& key)
1742 const std::string attr = img.attribute (
"EXIF:" + key);
1747 ColumnVector values (std::count (attr.begin (), attr.end (),
',') +1);
1749 std::istringstream sstream (attr);
1751 while (std::getline (sstream, sub,
char (
',')))
1753 sscanf (sub.c_str (),
"%f", &number);
1754 values(n++) = number;
1763 const std::string& key)
1765 const std::string attr = img.attribute (
"EXIF:" + key);
1771 ColumnVector values (std::count (attr.begin (), attr.end (),
',') +1);
1773 std::istringstream sstream (attr);
1775 while (std::getline (sstream, sub,
','))
1777 sscanf (sub.c_str (),
"%i/%i", &numerator, &denominator);
1778 values(n++) =
double (numerator) /
double (denominator);
1789 @deftypefn {Loadable Function} {} __magick_finfo__ (@var{fname})\n\
1790 Read image information with GraphicsMagick or ImageMagick.\n\
1792 This is a private internal function not intended for direct use.\n\
1793 Use @code{imfinfo} instead.\n\
1795 @seealso{imfinfo, imformats, imread, imwrite}\n\
1805 if (args.length () < 1 || ! args(0).is_string ())
1812 std::vector<Magick::Image> imvec;
1817 const std::string format = imvec[0].magick ();
1837 static const char *fields[] =
1904 const std::string filetime = mtime.
strftime (
"%e-%b-%Y %H:%M:%S");
1911 error (
"imfinfo: error reading '%s': %s",
1912 filename.c_str (), fs.
error ().c_str ());
1920 const Magick::Image img = imvec[frame];
1930 std::string color_type;
1934 color_type =
"indexed";
1936 read_maps (const_cast<Magick::Image&> (img))(0).matrix_value ();
1940 switch (img.type ())
1942 case Magick::BilevelType:
1943 case Magick::GrayscaleType:
1944 case Magick::GrayscaleMatteType:
1945 color_type =
"grayscale";
1948 case Magick::TrueColorType:
1949 case Magick::TrueColorMatteType:
1950 color_type =
"truecolor";
1953 case Magick::PaletteType:
1954 case Magick::PaletteMatteType:
1956 color_type =
"indexed";
1959 case Magick::ColorSeparationType:
1960 case Magick::ColorSeparationMatteType:
1961 color_type =
"CMYK";
1965 color_type =
"undefined";
1977 double* chroma_fvec = chromaticities.
fortran_vec ();
1978 img.chromaWhitePoint (&chroma_fvec[0], &chroma_fvec[1]);
1979 img.chromaRedPrimary (&chroma_fvec[2], &chroma_fvec[3]);
1980 img.chromaGreenPrimary (&chroma_fvec[4], &chroma_fvec[5]);
1981 img.chromaBluePrimary (&chroma_fvec[6], &chroma_fvec[7]);
1982 if (chromaticities.
nnz () == 0)
1996 info_frame.
setfield (
"Compression",
1998 info_frame.
setfield (
"Orientation",
2000 info_frame.
setfield (
"ResolutionUnit",
2009 Magick::Image& cimg =
const_cast<Magick::Image&
> (img);
2018 static const char *base_exif_str_fields[] =
2029 static const string_vector base_exif_str (base_exif_str_fields);
2033 info_frame.
setfield (base_exif_str[field],
2035 fill_exif (info_frame, cimg, base_exif_str[field]);
2040 if (! cimg.attribute (
"EXIF:ExifVersion").empty ())
2046 static const char *exif_str_fields[] =
2050 "DateTimeDigitized",
2053 "SubSecTimeOriginal",
2054 "SubSecTimeDigitized",
2061 "SpectralSensitivity",
2071 fill_exif (camera, cimg, exif_str[field]);
2074 static const char *exif_int_fields[] =
2079 "PhotographicSensitivity",
2080 "StandardOutputSensitivity",
2081 "RecommendedExposureIndex",
2083 "ISOSpeedLatitudeyyy",
2084 "ISOSpeedLatitudezzz",
2085 "FocalPlaneResolutionUnit",
2086 "FocalLengthIn35mmFilm",
2109 "SubjectDistanceRange",
2118 static const char *exif_float_fields[] =
2121 "CompressedBitsPerPixel",
2124 "ShutterSpeedValue",
2127 "ExposureBiasValue",
2132 "FocalPlaneXResolution",
2133 "FocalPlaneYResolution",
2137 "LensSpecification",
2148 if (cimg.attribute (
"EXIF:GPSInfo") !=
"unknown")
2154 static const char *gps_str_fields[] =
2164 "GPSImgDirectionRef",
2166 "GPSDestLatitudeRef",
2167 "GPSDestLongitudeRef",
2168 "GPSDestBearingRef",
2169 "GPSDestDistanceRef",
2178 static const char *gps_int_fields[] =
2188 static const char *gps_float_fields[] =
2197 "GPSHPositioningError",
2220 if (format ==
"GIF")
2222 static std::map<octave_idx_type, std::string> disposal_methods
2226 methods[frame] = disposal_methods[imvec[frame].gifDisposeMethod ()];
2245 @deftypefn {Loadable Function} {} __magick_imformats__ (@var{formats})\n\
2246 Fill formats info with GraphicsMagick CoderInfo.\n\
2248 @seealso{imfinfo, imformats, imread, imwrite}\n\
2255 if (args.length () != 1 || ! args(0).is_map ())
2271 fmt.
setfield (
"multipage", coder.isMultiFrame () ?
true :
false);
2274 if (! coder.isReadable ())
2276 if (! coder.isWritable ())
2280 catch (Magick::Exception& e)
uint8NDArray uint8_array_value(void) const
void warning_with_id(const char *id, const char *fmt,...)
ColumnVector column_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
bool is_empty(void) const
bool is_range(void) const
std::string error(void) const
void delete_elements(const idx_vector &i)
unsigned int uint_value(bool req_int=false, bool frc_str_conv=false) const
bool is_uint16_type(void) const
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
static Range get_region_range(const octave_value ®ion)
std::string strftime(const std::string &fmt) const
octave_idx_type nelem(void) const
static bool is_indexed(const Magick::Image &img)
bool is_scalar_type(void) const
int int_value(bool req_int=false, bool frc_str_conv=false) const
static std::map< std::string, octave_idx_type > init_reverse_disposal_methods()
void error(const char *fmt,...)
static void read_file(const std::string &filename, std::vector< Magick::Image > &imvec)
void setfield(const std::string &key, const octave_value &val)
static octave_idx_type bitdepth_from_class()
static void write_file(const std::string &filename, const std::string &ext, std::vector< Magick::Image > &imvec)
static void maybe_initialize_magick(void)
octave_idx_type numel(void) const
double scalar_value(bool frc_str_conv=false) const
static void encode_bool_image(std::vector< Magick::Image > &imvec, const boolNDArray &img)
boolNDArray bool_array_value(bool warn=false) const
octave_idx_type rows(void) const
static octave_value magick_to_octave_value(const Magick::CompressionType &magick)
octave_idx_type nelem(void) const
Number of elements in the array.
static octave_value_list read_indexed_images(const std::vector< Magick::Image > &imvec, const Array< octave_idx_type > &frameidx, const octave_idx_type &nargout, const octave_scalar_map &options)
Cell cell_value(void) const
bool is_float_type(void) const
Array< std::string > cellstr_value(void) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
static std::string get_program_invocation_name(void)
static bool is_valid_exif(const std::string &val)
FloatNDArray float_array_value(bool frc_str_conv=false) const
bool is_bool_type(void) const
std::string string_value(bool force=false) const
Range range_value(void) const
std::complex< double > w(std::complex< double > z, double relerr=0)
void gripe_disabled_feature(const std::string &func, const std::string &feature, const std::string &pkg)
bool is_string(void) const
bool fast_elem_insert(octave_idx_type n, const octave_scalar_map &rhs)
void resize(const dim_vector &dv, const T &rfv)
static octave_int< T > max(void)
static void encode_indexed_images(std::vector< Magick::Image > &imvec, const T &img, const Matrix &cmap)
static void fill_exif_ints(octave_scalar_map &map, Magick::Image &img, const std::string &key)
static void fill_exif(octave_scalar_map &map, Magick::Image &img, const std::string &key)
octave_idx_type nnz(void) const
Count nonzero elements.
static octave_value_list read_maps(Magick::Image &img)
octave_value_list read_images(std::vector< Magick::Image > &imvec, const Array< octave_idx_type > &frameidx, const octave_idx_type &nargout, const octave_scalar_map &options)
static Magick::Image init_enconde_image(const octave_idx_type &nCols, const octave_idx_type &nRows, const octave_idx_type &bitdepth, const Magick::ImageType &type, const Magick::ClassType &klass)
void setfield(const std::string &key, const Cell &val)
void warning(const char *fmt,...)
charNDArray max(char d, const charNDArray &m)
octave_idx_type length(void) const
Number of elements in the array.
octave_time mtime(void) const
NDArray array_value(bool frc_str_conv=false) const
static std::map< std::string, octave_idx_type > calculate_region(const octave_scalar_map &options)
static octave_idx_type get_depth(Magick::Image &img)
bool is_uint8_type(void) const
static uint32NDArray img_float2uint(const T &img)
static std::map< octave_idx_type, std::string > init_disposal_methods()
static void encode_uint_image(std::vector< Magick::Image > &imvec, const T &img, const T &alpha)
octave_scalar_map checkelem(octave_idx_type n) const
octave_value getfield(const std::string &key) const
Array< int > int_vector_value(bool req_int=false, bool frc_str_conv=false, bool frc_vec_conv=false) const
#define DEFUN_DLD(name, args_name, nargout_name, doc)
const T * fortran_vec(void) const
bool is_single_type(void) const
static void fill_exif_floats(octave_scalar_map &map, Magick::Image &img, const std::string &key)
bool is_uint32_type(void) const
uint32NDArray uint32_array_value(void) const
uint16NDArray uint16_array_value(void) const
octave_idx_type columns(void) const
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))