- using namespace MagickCore;
- Magick::Image* image = new Magick::Image (content->path(0).string());
- _video_size = dcp::Size (image->columns(), image->rows());
- delete image;
+ boost::filesystem::path path = content->path(0).string ();
+ if (valid_j2k_file (path)) {
+ boost::uintmax_t size = boost::filesystem::file_size (path);
+ FILE* f = fopen_boost (path, "rb");
+ if (!f) {
+ throw FileError ("Could not open file for reading", path);
+ }
+ uint8_t* buffer = new uint8_t[size];
+ checked_fread (buffer, size, f, path);
+ fclose (f);
+ try {
+ _video_size = dcp::decompress_j2k (buffer, size, 0)->size ();
+ } catch (dcp::ReadError& e) {
+ delete[] buffer;
+ throw DecodeError (String::compose (_("Could not decode JPEG2000 file %1 (%2)"), path, e.what ()));
+ }
+ delete[] buffer;
+ } else {
+ FFmpegImageProxy proxy(content->path(0));
+ _video_size = proxy.image().image->size();
+ }