44 image = std::make_shared<Magick::Image>(path);
47 image->backgroundColor(Magick::Color(
"none"));
50 catch (
const Magick::Exception& e) {
52 throw InvalidFile(
"File could not be opened.", path);
56 info.has_audio =
false;
57 info.has_video =
true;
58 info.has_single_image =
true;
59 info.file_size = image->fileSize();
60 info.vcodec = image->format();
61 info.width = image->size().width();
62 info.height = image->size().height();
65 info.video_timebase =
info.fps.Reciprocal();
67 info.video_length = 60 * 60 *
info.fps.num;
68 info.duration =
static_cast<float>(
info.video_length /
info.fps.ToDouble());
77 info.display_ratio = dar;
99 "The ImageReader is closed. "
100 "Call Open() before calling this method.", path);
104 auto image_frame = std::make_shared<Frame>(
106 image->size().width(), image->size().height(),
111 image_frame->AddImage(qimage);
128 root[
"type"] =
"ImageReader";
143 catch (
const std::exception& e)
146 "JSON is invalid (missing keys or invalid data types)");
157 if (!root[
"path"].isNull())
158 path = root[
"path"].asString();
Header file for all Exception classes.
Header file for Frame class.
Header file for ImageReader class.
Header file for MagickUtilities (IM6/IM7 compatibility overlay).
#define MAGICK_IMAGE_ALPHA(im, a)
Header file for QtUtilities (compatibiity overlay).
This class represents a fraction.
void Reduce()
Reduce this fraction (i.e. 640/480 = 4/3).
void Open() override
Open File - which is called by the constructor automatically.
std::shared_ptr< Frame > GetFrame(int64_t requested_frame) override
ImageReader(const std::string &path, bool inspect_reader=true)
Constructor for ImageReader.
void SetJson(const std::string value) override
Load JSON string into this object.
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Json::Value JsonValue() const override
Generate Json::Value for this object.
std::string Json() const override
Generate JSON string of this object.
void Close() override
Close File.
Exception for files that can not be found or opened.
Exception for invalid JSON.
openshot::ReaderInfo info
Information about the current media file.
virtual void SetJsonValue(const Json::Value root)=0
Load Json::Value into this object.
virtual Json::Value JsonValue() const =0
Generate Json::Value for this object.
Exception when a reader is closed, and a frame is requested.
This namespace is the default namespace for all code in the openshot library.
std::shared_ptr< QImage > Magick2QImage(std::shared_ptr< Magick::Image >)
Convert Magick::Image to QImage.
const Json::Value stringToJson(const std::string value)