26 #if defined (HAVE_CONFIG_H)
40 #if defined (HAVE_MAGICK)
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::GreenChannel) == 1
127 && img.channelDepth (Magick::BlueChannel) == 1
128 && img.channelDepth (Magick::CyanChannel) == 1
129 && img.channelDepth (Magick::MagentaChannel) == 1
130 && img.channelDepth (Magick::YellowChannel) == 1
131 && img.channelDepth (Magick::BlackChannel) == 1
132 && img.channelDepth (Magick::OpacityChannel) == 1
133 && img.channelDepth (Magick::GrayChannel) == 1)
153 output =
Range (value, value);
158 double base = array(0);
159 double limit = array(array.
numel () - 1);
160 double incr = array(1) - base;
161 output =
Range (base, limit, incr);
164 error (
"__magick_read__: unknown datatype for Region option");
186 m_row_start = rows.
base () - 1;
187 m_col_start = cols.
base () - 1;
188 m_row_end = rows.
max () - 1;
189 m_col_end = cols.
max () - 1;
191 m_row_cache = m_row_end - m_row_start + 1;
192 m_col_cache = m_col_end - m_col_start + 1;
194 m_row_shift = m_col_cache * rows.
inc ();
195 m_col_shift = m_col_cache * (m_row_cache + rows.
inc () - 1) - cols.
inc ();
197 m_row_out = rows.
numel ();
198 m_col_out = cols.
numel ();
265 const Magick::ColorRGB c = img.colorMap (i);
266 cmap(i,0) = c.red ();
267 cmap(i,1) = c.green ();
268 cmap(i,2) = c.blue ();
269 amap(i) = c.alpha ();
277 template <
typename T>
284 typedef typename T::element_type P;
299 T img = T (
dim_vector (nRows, nCols, 1, nFrames));
300 P *img_fvec = img.fortran_vec ();
317 imvec[frameidx(frame)].getConstPixels (col_start, row_start,
318 col_cache, row_cache);
320 const Magick::IndexPacket *pix
321 = imvec[frameidx(frame)].getConstIndexes ();
327 img_fvec[idx++] =
static_cast<P
> (*pix);
344 =
read_maps (
const_cast<Magick::Image&
> (imvec[frameidx(def_elem)]));
349 if (imvec[def_elem].matte () && nargout >= 3)
351 const Matrix amap = maps(1).matrix_value ();
361 alpha_fvec[pix] = 1 - amap_fvec[
static_cast<int> (img_fvec[3])];
374 template <
typename T>
381 typedef typename T::element_type P;
423 if (imvec[def_elem].depth () == 32)
426 divisor = MaxRGB / ((uint64_t (1) << imvec[def_elem].depth ()) - 1);
435 Magick::ImageType
type = imvec[def_elem].type ();
436 if (
type == Magick::BilevelType && imvec[def_elem].matte ())
437 type = Magick::GrayscaleMatteType;
446 if (imvec[0].magick () ==
"PNG")
456 const std::string type_str
457 = imvec[0].attribute (
"PNG:IHDR.color-type-orig");
460 type = Magick::GrayscaleType;
461 else if (type_str ==
"2")
462 type = Magick::TrueColorType;
463 else if (type_str ==
"6")
464 type = Magick::TrueColorMatteType;
465 else if (type_str ==
"4")
466 type = Magick::GrayscaleMatteType;
472 if (imvec[0].matte ())
474 if (
type == Magick::GrayscaleType)
475 type = Magick::GrayscaleMatteType;
476 else if (
type == Magick::TrueColorType)
477 type = Magick::TrueColorMatteType;
487 case Magick::GrayscaleMatteType:
488 type = Magick::GrayscaleType;
491 case Magick::PaletteMatteType:
492 type = Magick::PaletteType;
495 case Magick::TrueColorMatteType:
496 type = Magick::TrueColorType;
499 case Magick::ColorSeparationMatteType:
500 type = Magick::ColorSeparationType;
513 case Magick::BilevelType:
514 case Magick::GrayscaleType:
516 img = T (
dim_vector (nRows, nCols, 1, nFrames));
517 P *img_fvec = img.fortran_vec ();
524 const Magick::PixelPacket *pix
525 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
526 col_cache, row_cache);
532 img_fvec[idx++] = pix->red / divisor;
541 case Magick::GrayscaleMatteType:
543 img = T (
dim_vector (nRows, nCols, 1, nFrames));
544 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
545 P *img_fvec = img.fortran_vec ();
546 P *a_fvec = alpha.fortran_vec ();
553 const Magick::PixelPacket *pix
554 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
555 col_cache, row_cache);
561 img_fvec[idx] = pix->red / divisor;
562 a_fvec[idx] = (MaxRGB - pix->opacity) / divisor;
573 case Magick::PaletteType:
574 case Magick::TrueColorType:
576 img = T (
dim_vector (nRows, nCols, 3, nFrames));
577 P *img_fvec = img.fortran_vec ();
584 const Magick::PixelPacket *pix
585 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
586 col_cache, row_cache);
590 P *gbuf = img_fvec + color_stride;
591 P *bbuf = img_fvec + color_stride * 2;
597 rbuf[idx] = pix->red / divisor;
598 gbuf[idx] = pix->green / divisor;
599 bbuf[idx] = pix->blue / divisor;
605 img_fvec += frame_stride;
610 case Magick::PaletteMatteType:
611 case Magick::TrueColorMatteType:
613 img = T (
dim_vector (nRows, nCols, 3, nFrames));
614 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
615 P *img_fvec = img.fortran_vec ();
616 P *a_fvec = alpha.fortran_vec ();
627 const Magick::PixelPacket *pix
628 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
629 col_cache, row_cache);
633 P *gbuf = img_fvec + color_stride;
634 P *bbuf = img_fvec + color_stride * 2;
640 rbuf[idx] = pix->red / divisor;
641 gbuf[idx] = pix->green / divisor;
642 bbuf[idx] = pix->blue / divisor;
643 a_fvec[a_idx++] = (MaxRGB - pix->opacity) / divisor;
649 img_fvec += frame_stride;
655 case Magick::ColorSeparationType:
657 img = T (
dim_vector (nRows, nCols, 4, nFrames));
658 P *img_fvec = img.fortran_vec ();
665 const Magick::PixelPacket *pix
666 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
667 col_cache, row_cache);
671 P *mbuf = img_fvec + color_stride;
672 P *ybuf = img_fvec + color_stride * 2;
673 P *kbuf = img_fvec + color_stride * 3;
679 cbuf[idx] = pix->red / divisor;
680 mbuf[idx] = pix->green / divisor;
681 ybuf[idx] = pix->blue / divisor;
682 kbuf[idx] = pix->opacity / divisor;
688 img_fvec += frame_stride;
694 case Magick::ColorSeparationMatteType:
696 img = T (
dim_vector (nRows, nCols, 4, nFrames));
697 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
698 P *img_fvec = img.fortran_vec ();
699 P *a_fvec = alpha.fortran_vec ();
710 const Magick::PixelPacket *pix
711 = imvec[frameidx(frame)].getConstPixels (col_start, row_start,
712 col_cache, row_cache);
715 const Magick::IndexPacket *apix
716 = imvec[frameidx(frame)].getConstIndexes ();
720 P *mbuf = img_fvec + color_stride;
721 P *ybuf = img_fvec + color_stride * 2;
722 P *kbuf = img_fvec + color_stride * 3;
728 cbuf[idx] = pix->red / divisor;
729 mbuf[idx] = pix->green / divisor;
730 ybuf[idx] = pix->blue / divisor;
731 kbuf[idx] = pix->opacity / divisor;
732 a_fvec[a_idx++] = (MaxRGB - *apix) / divisor;
738 img_fvec += frame_stride;
745 error (
"__magick_read__: unknown Magick++ image type");
755 read_file (
const std::string& filename, std::vector<Magick::Image>& imvec)
759 Magick::readImages (&imvec, filename);
761 catch (Magick::Warning&
w)
763 warning (
"Magick++ warning: %s",
w.what ());
765 catch (Magick::Exception& e)
767 error (
"Magick++ exception: %s", e.what ());
774 static bool initialized =
false;
780 const char *static_locale = setlocale (LC_ALL,
nullptr);
781 const std::string locale = (static_locale ? static_locale :
"");
783 const std::string program_name
785 Magick::InitializeMagick (program_name.c_str ());
788 setlocale (LC_ALL, locale.c_str ());
809 if (QuantumDepth < 16)
811 "your version of %s limits images to %d bits per pixel\n",
812 MagickPackageName, QuantumDepth);
820 DEFUN (__magick_read__, args, nargout,
831 #if defined (HAVE_MAGICK)
833 if (args.length () != 2 || ! args(0).is_string ())
839 = args(1).xscalar_map_value (
"__magick_read__: OPTIONS must be a struct");
843 std::vector<Magick::Image> imvec;
844 read_file (args(0).string_value (), imvec);
858 frameidx = indexes.
xint_vector_value (
"__magick_read__: invalid value for Index/Frame");
866 if (frameidx(i) < 0 || frameidx(i) > nFrames - 1)
871 error (
"imread: index/frames specified are outside the number of images");
881 const unsigned int nRows = imvec[frameidx(0)].rows ();
882 const unsigned int nCols = imvec[frameidx(0)].columns ();
886 if (nRows != imvec[frameidx(frame)].rows ()
887 || nCols != imvec[frameidx(frame)].columns ())
889 error (
"imread: all frames must have the same size but frame "
890 "%" OCTAVE_IDX_TYPE_FORMAT
" is different",
900 output = read_indexed_images<boolNDArray> (imvec, frameidx,
903 output = read_indexed_images<uint8NDArray> (imvec, frameidx,
905 else if (depth <= 16)
906 output = read_indexed_images<uint16NDArray> (imvec, frameidx,
909 error (
"imread: indexed images with depths greater than 16-bit are not supported");
915 output = read_images<boolNDArray> (imvec, frameidx, nargout, options);
917 output = read_images<uint8NDArray> (imvec, frameidx, nargout, options);
918 else if (depth <= 16)
919 output = read_images<uint16NDArray> (imvec, frameidx, nargout, options);
920 else if (depth <= 32)
921 output = read_images<FloatNDArray> (imvec, frameidx, nargout, options);
923 error (
"imread: reading of images with %" OCTAVE_IDX_TYPE_FORMAT
924 "-bit depth is not supported", depth);
931 octave_unused_parameter (args);
932 octave_unused_parameter (nargout);
944 #if defined (HAVE_MAGICK)
946 template <
typename T>
950 typedef typename T::element_type P;
954 const P *img_fvec = img.fortran_vec ();
959 out_fvec[idx] = img_fvec[idx] *
max;
966 template <
typename T>
970 typedef typename T::element_type P;
972 =
sizeof (P) * std::numeric_limits<unsigned char>::digits;
979 const Magick::ImageType&
type,
980 const Magick::ClassType& klass)
982 Magick::Image img (Magick::Geometry (nCols, nRows),
"black");
986 img.classType (klass);
990 img.depth (bitdepth);
993 case Magick::GrayscaleMatteType:
994 case Magick::TrueColorMatteType:
995 case Magick::ColorSeparationMatteType:
996 case Magick::PaletteMatteType:
1007 template <
typename T>
1013 typedef typename T::element_type P;
1014 const octave_idx_type nFrames = (img.ndims () < 4 ? 1 : img.dims ()(3));
1022 std::vector<Magick::ColorRGB> colormap;
1028 colormap.push_back (Magick::ColorRGB (cmap_fvec[map_idx],
1029 cmap_fvec[map_idx + G_offset],
1030 cmap_fvec[map_idx + B_offset]));
1038 Magick::PaletteType,
1039 Magick::PseudoClass);
1042 m_img.colorMapSize (cmap_size);
1044 m_img.colorMap (map_idx, colormap[map_idx]);
1055 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1056 Magick::IndexPacket *ind = m_img.getIndexes ();
1057 const P *img_fvec = img.fortran_vec ();
1064 ind[GM_idx] = double (*img_fvec);
1065 pix[GM_idx] = m_img.colorMap (
double (*img_fvec));
1069 GM_idx -= nCols * nRows - 1;
1073 m_img.syncPixels ();
1074 imvec.push_back (m_img);
1086 const Magick::Color white (
"white");
1099 Magick::GrayscaleType,
1100 Magick::DirectClass);
1102 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1108 if (img_fvec[img_idx])
1109 pix[GM_idx] = white;
1114 GM_idx -= nCols * nRows - 1;
1117 m_img.syncPixels ();
1120 m_img.type (Magick::BilevelType);
1121 imvec.push_back (m_img);
1125 template <
typename T>
1128 const T& img,
const T& alpha)
1130 typedef typename T::element_type P;
1131 const octave_idx_type channels = (img.ndims () < 3 ? 1 : img.dims ()(2));
1132 const octave_idx_type nFrames = (img.ndims () < 4 ? 1 : img.dims ()(3));
1137 Magick::ImageType
type;
1138 const bool has_alpha = ! alpha.isempty ();
1143 type = Magick::GrayscaleMatteType;
1145 type = Magick::GrayscaleType;
1150 type = Magick::TrueColorMatteType;
1152 type = Magick::TrueColorType;
1157 type = Magick::ColorSeparationMatteType;
1159 type = Magick::ColorSeparationType;
1164 error (
"__magick_write__: wrong size on 3rd dimension");
1174 const double divisor =
static_cast<double> ((uint64_t (1) << bitdepth) - 1)
1177 const P *img_fvec = img.fortran_vec ();
1178 const P *a_fvec = alpha.fortran_vec ();
1181 case Magick::GrayscaleType:
1189 Magick::DirectClass);
1191 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1198 Magick::Color c (grey, grey, grey);
1203 GM_idx -= nCols * nRows - 1;
1206 m_img.syncPixels ();
1207 imvec.push_back (m_img);
1212 case Magick::GrayscaleMatteType:
1220 Magick::DirectClass);
1222 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1229 Magick::Color c (grey, grey, grey,
1236 GM_idx -= nCols * nRows - 1;
1239 m_img.syncPixels ();
1240 imvec.push_back (m_img);
1245 case Magick::TrueColorType:
1256 Magick::DirectClass);
1258 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1271 GM_idx -= nCols * nRows - 1;
1274 m_img.syncPixels ();
1275 imvec.push_back (m_img);
1276 img_fvec += B_offset;
1281 case Magick::TrueColorMatteType:
1292 Magick::DirectClass);
1294 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1309 GM_idx -= nCols * nRows - 1;
1312 m_img.syncPixels ();
1313 imvec.push_back (m_img);
1314 img_fvec += B_offset;
1319 case Magick::ColorSeparationType:
1331 Magick::DirectClass);
1333 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1347 GM_idx -= nCols * nRows - 1;
1350 m_img.syncPixels ();
1351 imvec.push_back (m_img);
1352 img_fvec += K_offset;
1357 case Magick::ColorSeparationMatteType:
1369 Magick::DirectClass);
1371 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1372 Magick::IndexPacket *ind = m_img.getIndexes ();
1388 GM_idx -= nCols * nRows - 1;
1391 m_img.syncPixels ();
1392 imvec.push_back (m_img);
1393 img_fvec += K_offset;
1399 error (
"__magick_write__: unrecognized Magick::ImageType");
1406 static std::map<octave_idx_type, std::string>
1424 static std::map<octave_idx_type, std::string> methods;
1425 if (methods.empty ())
1427 methods[0] =
"doNotSpecify";
1428 methods[1] =
"leaveInPlace";
1429 methods[2] =
"restoreBG";
1430 methods[3] =
"restorePrevious";
1434 static std::map<std::string, octave_idx_type>
1437 static std::map<std::string, octave_idx_type> methods;
1438 if (methods.empty ())
1440 methods[
"donotspecify"] = 0;
1441 methods[
"leaveinplace"] = 1;
1442 methods[
"restorebg"] = 2;
1443 methods[
"restoreprevious"] = 3;
1450 const std::string& ext,
1451 std::vector<Magick::Image>& imvec)
1455 Magick::writeImages (imvec.begin (), imvec.end (), ext +
':' + filename);
1457 catch (Magick::Warning&
w)
1459 warning (
"Magick++ warning: %s",
w.what ());
1461 catch (Magick::ErrorCoder& e)
1463 warning (
"Magick++ coder error: %s", e.what ());
1465 catch (Magick::Exception& e)
1467 error (
"Magick++ exception: %s", e.what ());
1473 DEFUN (__magick_write__, args, ,
1484 #if defined (HAVE_MAGICK)
1486 if (args.length () != 5 || ! args(0).is_string () || ! args(1).is_string ())
1491 const std::string filename = args(0).string_value ();
1492 const std::string ext = args(1).string_value ();
1495 = args(4).xscalar_map_value (
"__magick_write__: OPTIONS must be a struct");
1498 const Matrix cmap = args(3).xmatrix_value (
"__magick_write__: invalid MAP");
1500 std::vector<Magick::Image> imvec;
1527 clip_img = img_float2uint<FloatNDArray>
1529 clip_alpha = img_float2uint<FloatNDArray>
1534 clip_img = img_float2uint<NDArray> (img.
array_value ());
1535 clip_alpha = img_float2uint<NDArray> (alpha.
array_value ());
1537 encode_uint_image<uint32NDArray> (imvec, clip_img, clip_alpha);
1540 error (
"__magick_write__: image type not supported");
1554 error (
"__magick_write__: indexed image must be uint8, uint16 or float.");
1556 static std::map<std::string, octave_idx_type> disposal_methods
1568 imvec[i].quality (quality);
1569 imvec[i].animationDelay (delaytime(i));
1570 imvec[i].gifDisposeMethod (disposal_methods[disposalmethod(i)]);
1578 std::vector<Magick::Image> ini_imvec;
1581 if (ini_imvec.size () > 0)
1583 ini_imvec.insert (ini_imvec.end (), imvec.begin (), imvec.end ());
1584 ini_imvec.swap (imvec);
1614 const std::string compression
1617 #define COMPRESS_MAGICK_IMAGE_VECTOR(GM_TYPE) \
1618 for (std::vector<Magick::Image>::size_type i = 0; i < imvec.size (); i++) \
1619 imvec[i].compressType (GM_TYPE)
1621 if (compression ==
"none")
1623 else if (compression ==
"bzip")
1625 else if (compression ==
"fax3")
1627 else if (compression ==
"fax4")
1629 else if (compression ==
"jpeg")
1631 else if (compression ==
"lzw")
1633 else if (compression ==
"rle")
1635 else if (compression ==
"deflate")
1638 #undef COMPRESS_MAGICK_IMAGE_VECTOR
1646 octave_unused_parameter (args);
1662 DEFUN (__magick_ping__, args, ,
1672 #if defined (HAVE_MAGICK)
1674 if (args.length () < 1 || ! args(0).is_string ())
1679 const std::string filename = args(0).string_value ();
1682 if (args.length () > 1)
1683 idx = args(1).int_value () -1;
1692 img.ping (filename);
1694 catch (Magick::Warning&
w)
1696 warning (
"Magick++ warning: %s",
w.what ());
1698 catch (Magick::Exception& e)
1700 error (
"Magick++ exception: %s", e.what ());
1703 static const char *fields[] = {
"rows",
"columns",
"format",
nullptr};
1713 octave_unused_parameter (args);
1720 #if defined (HAVE_MAGICK)
1727 case Magick::NoCompression:
1729 case Magick::BZipCompression:
1731 case Magick::FaxCompression:
1733 case Magick::Group4Compression:
1735 case Magick::JPEGCompression:
1737 case Magick::LZWCompression:
1739 case Magick::RLECompression:
1743 case Magick::ZipCompression:
1771 case Magick::LSBEndian:
1773 case Magick::MSBEndian:
1786 case Magick::TopLeftOrientation:
1788 case Magick::TopRightOrientation:
1790 case Magick::BottomRightOrientation:
1792 case Magick::BottomLeftOrientation:
1794 case Magick::LeftTopOrientation:
1796 case Magick::RightTopOrientation:
1798 case Magick::RightBottomOrientation:
1800 case Magick::LeftBottomOrientation:
1812 case Magick::PixelsPerInchResolution:
1814 case Magick::PixelsPerCentimeterResolution:
1826 return (! val.empty () && val !=
"unknown");
1831 const std::string& key)
1833 const std::string attr = img.attribute (
"EXIF:" + key);
1841 const std::string& key)
1843 const std::string attr = img.attribute (
"EXIF:" + key);
1848 ColumnVector values (std::count (attr.begin (), attr.end (),
',') +1);
1850 std::istringstream sstream (attr);
1852 while (std::getline (sstream, sub,
char (
',')))
1854 sscanf (sub.c_str (),
"%f", &number);
1855 values(
n++) = number;
1864 const std::string& key)
1866 const std::string attr = img.attribute (
"EXIF:" + key);
1872 ColumnVector values (std::count (attr.begin (), attr.end (),
',') +1);
1874 std::istringstream sstream (attr);
1876 while (std::getline (sstream, sub,
','))
1878 sscanf (sub.c_str (),
"%i/%i", &numerator, &denominator);
1879 values(
n++) = double (numerator) / double (denominator);
1888 DEFUN (__magick_finfo__, args, ,
1899 #if defined (HAVE_MAGICK)
1901 if (args.length () < 1 || ! args(0).is_string ())
1906 const std::string filename = args(0).string_value ();
1908 std::vector<Magick::Image> imvec;
1912 const std::string
format = imvec[0].magick ();
1932 static const char *fields[] =
1997 error (
"imfinfo: error reading '%s': %s", filename.c_str (),
1998 fs.
error ().c_str ());
2001 const std::string filetime = mtime.
strftime (
"%e-%b-%Y %H:%M:%S");
2011 const Magick::Image img = imvec[frame];
2021 std::string color_type;
2025 color_type =
"indexed";
2026 cmap =
read_maps (
const_cast<Magick::Image&
> (img))(0).matrix_value ();
2030 switch (img.type ())
2032 case Magick::BilevelType:
2033 case Magick::GrayscaleType:
2034 case Magick::GrayscaleMatteType:
2035 color_type =
"grayscale";
2038 case Magick::TrueColorType:
2039 case Magick::TrueColorMatteType:
2040 color_type =
"truecolor";
2043 case Magick::PaletteType:
2044 case Magick::PaletteMatteType:
2046 color_type =
"indexed";
2049 case Magick::ColorSeparationType:
2050 case Magick::ColorSeparationMatteType:
2051 color_type =
"CMYK";
2055 color_type =
"undefined";
2067 double *chroma_fvec = chromaticities.
fortran_vec ();
2068 img.chromaWhitePoint (&chroma_fvec[0], &chroma_fvec[1]);
2069 img.chromaRedPrimary (&chroma_fvec[2], &chroma_fvec[3]);
2070 img.chromaGreenPrimary (&chroma_fvec[4], &chroma_fvec[5]);
2071 img.chromaBluePrimary (&chroma_fvec[6], &chroma_fvec[7]);
2072 if (chromaticities.
nnz () == 0)
2086 info_frame.
setfield (
"Compression",
2088 info_frame.
setfield (
"Orientation",
2090 info_frame.
setfield (
"ResolutionUnit",
2099 Magick::Image& cimg =
const_cast<Magick::Image&
> (img);
2108 static const char *base_exif_str_fields[] =
2119 static const string_vector base_exif_str (base_exif_str_fields);
2123 info_frame.
setfield (base_exif_str[field],
2125 fill_exif (info_frame, cimg, base_exif_str[field]);
2130 if (! cimg.attribute (
"EXIF:ExifVersion").empty ())
2136 static const char *exif_str_fields[] =
2140 "DateTimeDigitized",
2143 "SubSecTimeOriginal",
2144 "SubSecTimeDigitized",
2151 "SpectralSensitivity",
2161 fill_exif (camera, cimg, exif_str[field]);
2164 static const char *exif_int_fields[] =
2169 "PhotographicSensitivity",
2170 "StandardOutputSensitivity",
2171 "RecommendedExposureIndex",
2173 "ISOSpeedLatitudeyyy",
2174 "ISOSpeedLatitudezzz",
2175 "FocalPlaneResolutionUnit",
2176 "FocalLengthIn35mmFilm",
2199 "SubjectDistanceRange",
2208 static const char *exif_float_fields[] =
2211 "CompressedBitsPerPixel",
2214 "ShutterSpeedValue",
2217 "ExposureBiasValue",
2222 "FocalPlaneXResolution",
2223 "FocalPlaneYResolution",
2227 "LensSpecification",
2238 if (cimg.attribute (
"EXIF:GPSInfo") !=
"unknown")
2244 static const char *gps_str_fields[] =
2254 "GPSImgDirectionRef",
2256 "GPSDestLatitudeRef",
2257 "GPSDestLongitudeRef",
2258 "GPSDestBearingRef",
2259 "GPSDestDistanceRef",
2268 static const char *gps_int_fields[] =
2278 static const char *gps_float_fields[] =
2287 "GPSHPositioningError",
2312 static std::map<octave_idx_type, std::string> disposal_methods
2316 methods[frame] = disposal_methods[imvec[frame].gifDisposeMethod ()];
2327 octave_unused_parameter (args);
2339 DEFUN (__magick_formats__, args, ,
2347 if (args.length () != 1 || ! args(0).isstruct ())
2352 #if defined (HAVE_MAGICK)
2364 fmt.
setfield (
"multipage", coder.isMultiFrame () ?
true :
false);
2367 if (! coder.isReadable ())
2369 if (! coder.isWritable ())
2373 catch (Magick::Exception& e)
2388 return ovl (formats);
#define COMPRESS_MAGICK_IMAGE_VECTOR(GM_TYPE)
static void write_file(const std::string &filename, const std::string &ext, std::vector< Magick::Image > &imvec)
static bool is_indexed(const Magick::Image &img)
static octave_idx_type get_depth(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 void encode_indexed_images(std::vector< Magick::Image > &imvec, const T &img, const Matrix &cmap)
static void encode_uint_image(std::vector< Magick::Image > &imvec, const T &img, const T &alpha)
static octave_value magick_to_octave_value(const Magick::CompressionType &magick)
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)
static bool is_valid_exif(const std::string &val)
static uint32NDArray img_float2uint(const T &img)
static void fill_exif_ints(octave_scalar_map &map, Magick::Image &img, const std::string &key)
static octave_idx_type bitdepth_from_class()
static void read_file(const std::string &filename, std::vector< Magick::Image > &imvec)
static Range get_region_range(const octave_value ®ion)
static void maybe_initialize_magick(void)
static void fill_exif(octave_scalar_map &map, Magick::Image &img, const std::string &key)
static std::map< octave_idx_type, std::string > init_disposal_methods()
static std::map< std::string, octave_idx_type > init_reverse_disposal_methods()
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)
static void encode_bool_image(std::vector< Magick::Image > &imvec, const boolNDArray &img)
static void fill_exif_floats(octave_scalar_map &map, Magick::Image &img, const std::string &key)
static octave_value_list read_maps(Magick::Image &img)
charNDArray max(char d, const charNDArray &m)
octave_idx_type nnz(void) const
Count nonzero elements.
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type columns(void) const
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type rows(void) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
int ndims(void) const
Size of the specified dimension.
const T * fortran_vec(void) const
Size of the specified dimension.
bool isempty(void) const
Size of the specified dimension.
octave_idx_type numel(void) const
Vector representing the dimensions (size) of an Array.
octave_idx_type row_end(void) const
octave_idx_type col_end(void) const
octave_idx_type m_col_shift
octave_idx_type m_row_cache
octave_idx_type col_out(void) const
octave_idx_type col_cache(void) const
octave_idx_type row_out(void) const
octave_idx_type m_row_shift
octave_idx_type m_row_start
octave_idx_type col_shift(void) const
octave_idx_type m_row_out
octave_idx_type m_col_start
image_region(image_region &&)=default
octave_idx_type m_col_out
octave_idx_type row_cache(void) const
octave_idx_type col_start(void) const
~image_region(void)=default
octave_idx_type m_col_cache
image_region(const image_region &)=default
octave_idx_type m_row_end
octave_idx_type row_start(void) const
octave_idx_type row_shift(void) const
octave_idx_type m_col_end
image_region(const octave_scalar_map &options)
sys::time mtime(void) const
std::string error(void) const
std::string strftime(const std::string &fmt) const
static std::string get_program_invocation_name(void)
static octave_int< T > max(void)
void delete_elements(const idx_vector &i)
octave_scalar_map checkelem(octave_idx_type n) const
void setfield(const std::string &key, const Cell &val)
octave_idx_type numel(void) const
string_vector fieldnames(void) const
bool fast_elem_insert(octave_idx_type n, const octave_scalar_map &rhs)
void setfield(const std::string &key, const octave_value &val)
octave_value getfield(const std::string &key) const
boolNDArray bool_array_value(bool warn=false) const
uint16NDArray uint16_array_value(void) const
int int_value(bool req_int=false, bool frc_str_conv=false) const
bool is_uint16_type(void) const
bool is_scalar_type(void) const
Range range_value(void) const
Array< int > xint_vector_value(const char *fmt,...) const
bool is_string(void) const
Cell cell_value(void) const
bool is_uint32_type(void) const
uint8NDArray uint8_array_value(void) const
double scalar_value(bool frc_str_conv=false) const
std::string string_value(bool force=false) const
bool is_matrix_type(void) const
bool is_range(void) const
NDArray array_value(bool frc_str_conv=false) const
bool is_single_type(void) const
uint32NDArray uint32_array_value(void) const
ColumnVector column_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
Array< std::string > cellstr_value(void) const
bool is_uint8_type(void) const
unsigned int uint_value(bool req_int=false, bool frc_str_conv=false) const
bool islogical(void) const
octave_idx_type numel(void) const
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning(const char *fmt,...)
void warning_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
std::complex< double > w(std::complex< double > z, double relerr=0)
size_t format(std::ostream &os, const char *fmt,...)
T::size_type numel(const T &str)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.