X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Ftool%2Fmain.cpp;h=01f4b645b3797a701cde09c18f85022ebf584d16;hb=78aeb61398c711707f2f2e9131137df316221caf;hp=77281c8fc8bcf2529198ff4befb11c2456d25527;hpb=8718cdddf1d78894f8f93dcacd0918289c502d1b;p=synfig.git diff --git a/synfig-core/trunk/src/tool/main.cpp b/synfig-core/trunk/src/tool/main.cpp index 77281c8..01f4b64 100644 --- a/synfig-core/trunk/src/tool/main.cpp +++ b/synfig-core/trunk/src/tool/main.cpp @@ -259,6 +259,18 @@ struct Job int quality; bool sifout; bool list_canvases; + + bool canvas_info, canvas_info_all, canvas_info_time_start, canvas_info_time_end, canvas_info_frame_rate, + canvas_info_frame_start, canvas_info_frame_end, canvas_info_w, canvas_info_h, canvas_info_image_aspect, + canvas_info_pw, canvas_info_ph, canvas_info_pixel_aspect, canvas_info_tl, canvas_info_br, + canvas_info_physical_w, canvas_info_physical_h, canvas_info_x_res, canvas_info_y_res, canvas_info_span, + canvas_info_interlaced, canvas_info_antialias, canvas_info_clamp, canvas_info_flags, canvas_info_focus, + canvas_info_bg_color, canvas_info_metadata; + + Job() + { + canvas_info = canvas_info_all = canvas_info_time_start = canvas_info_time_end = canvas_info_frame_rate = canvas_info_frame_start = canvas_info_frame_end = canvas_info_w = canvas_info_h = canvas_info_image_aspect = canvas_info_pw = canvas_info_ph = canvas_info_pixel_aspect = canvas_info_tl = canvas_info_br = canvas_info_physical_w = canvas_info_physical_h = canvas_info_x_res = canvas_info_y_res = canvas_info_span = canvas_info_interlaced = canvas_info_antialias = canvas_info_clamp = canvas_info_flags = canvas_info_focus = canvas_info_bg_color = canvas_info_metadata = false; + }; }; typedef list arg_list_t; @@ -336,6 +348,7 @@ void display_help(int amount) Argument("--dpi-y","",_("Set the physical Y resolution (dots-per-inch)")); Argument("--list-canvases",NULL,_("List the exported canvases in the composition")); + Argument("--canvas-info","",_("Print out specified details of the root canvas")); Argument("--append","",_("Append layers in to composition")); Argument("--layer-info","",_("Print out layer's description, parameter info, etc.")); @@ -534,10 +547,11 @@ int process_global_flags(arg_list_t &arg_list) /* true if the given flag takes an extra parameter */ bool flag_requires_value(String flag) { - return (flag=="-a" || flag=="-c" || flag=="-g" || flag=="-h" || flag=="-o" || - flag=="-Q" || flag=="-s" || flag=="-t" || flag=="-T" || flag=="-w" || - flag=="--append" || flag=="--begin-time" || flag=="--dpi" || flag=="--dpi-x" || flag=="--dpi-y" || - flag=="--end-time" || flag=="--fps" || flag=="--layer-info" || flag=="--start-time" || flag=="--time" ); + return (flag=="-a" || flag=="-c" || flag=="-g" || flag=="-h" || flag=="-o" || + flag=="-Q" || flag=="-s" || flag=="-t" || flag=="-T" || flag=="-w" || + flag=="--append" || flag=="--begin-time" || flag=="--canvas-info"|| flag=="--dpi" || flag=="--dpi-x" || + flag=="--dpi-y" || flag=="--end-time" || flag=="--fps" || flag=="--layer-info" || flag=="--start-time" || + flag=="--time" ); } int extract_arg_cluster(arg_list_t &arg_list,arg_list_t &cluster) @@ -682,24 +696,16 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc) else if (flag_requires_value(*iter)) iter=next++; } - if(w&&h) + if (w||h) { + if (!w) + w = desc.get_w() * h / desc.get_h(); + else if (!h) + h = desc.get_h() * w / desc.get_w(); + desc.set_wh(w,h); VERBOSE_OUT(1)<children()); @@ -855,6 +935,182 @@ void list_child_canvases(string prefix, Canvas::Handle canvas) } } +void list_canvas_info(Job job) +{ + Canvas::Handle canvas(job.canvas); + const RendDesc &rend_desc(canvas->rend_desc()); + + if (job.canvas_info_all || job.canvas_info_time_start) + { + cout << endl << "# " << _("Start Time") << endl; + cout << "time_start" << "=" << rend_desc.get_time_start().get_string().c_str() << endl; + } + + if (job.canvas_info_all || job.canvas_info_time_end) + { + cout << endl << "# " << _("End Time") << endl; + cout << "time_end" << "=" << rend_desc.get_time_end().get_string().c_str() << endl; + } + + if (job.canvas_info_all || job.canvas_info_frame_rate) + { + cout << endl << "# " << _("Frame Rate") << endl; + cout << "frame_rate" << "=" << rend_desc.get_frame_rate() << endl; + } + + if (job.canvas_info_all || job.canvas_info_frame_start) + { + cout << endl << "# " << _("Start Frame") << endl; + cout << "frame_start" << "=" << rend_desc.get_frame_start() << endl; + } + + if (job.canvas_info_all || job.canvas_info_frame_end) + { + cout << endl << "# " << _("End Frame") << endl; + cout << "frame_end" << "=" << rend_desc.get_frame_end() << endl; + } + + if (job.canvas_info_all) + cout << endl; + + if (job.canvas_info_all || job.canvas_info_w) + { + cout << endl << "# " << _("Width") << endl; + cout << "w" << "=" << rend_desc.get_w() << endl; + } + + if (job.canvas_info_all || job.canvas_info_h) + { + cout << endl << "# " << _("Height") << endl; + cout << "h" << "=" << rend_desc.get_h() << endl; + } + + if (job.canvas_info_all || job.canvas_info_image_aspect) + { + cout << endl << "# " << _("Image Aspect Ratio") << endl; + cout << "image_aspect" << "=" << rend_desc.get_image_aspect() << endl; + } + + if (job.canvas_info_all) + cout << endl; + + if (job.canvas_info_all || job.canvas_info_pw) + { + cout << endl << "# " << _("Pixel Width") << endl; + cout << "pw" << "=" << rend_desc.get_pw() << endl; + } + + if (job.canvas_info_all || job.canvas_info_ph) + { + cout << endl << "# " << _("Pixel Height") << endl; + cout << "ph" << "=" << rend_desc.get_ph() << endl; + } + + if (job.canvas_info_all || job.canvas_info_pixel_aspect) + { + cout << endl << "# " << _("Pixel Aspect Ratio") << endl; + cout << "pixel_aspect" << "=" << rend_desc.get_pixel_aspect() << endl; + } + + if (job.canvas_info_all) + cout << endl; + + if (job.canvas_info_all || job.canvas_info_tl) + { + cout << endl << "# " << _("Top Left") << endl; + cout << "tl" << "=" << rend_desc.get_tl()[0] + << " " << rend_desc.get_tl()[1] << endl; + } + + if (job.canvas_info_all || job.canvas_info_br) + { + cout << endl << "# " << _("Bottom Right") << endl; + cout << "br" << "=" << rend_desc.get_br()[0] + << " " << rend_desc.get_br()[1] << endl; + } + + if (job.canvas_info_all || job.canvas_info_physical_w) + { + cout << endl << "# " << _("Physical Width") << endl; + cout << "physical_w" << "=" << rend_desc.get_physical_w() << endl; + } + + if (job.canvas_info_all || job.canvas_info_physical_h) + { + cout << endl << "# " << _("Physical Height") << endl; + cout << "physical_h" << "=" << rend_desc.get_physical_h() << endl; + } + + if (job.canvas_info_all || job.canvas_info_x_res) + { + cout << endl << "# " << _("X Resolution") << endl; + cout << "x_res" << "=" << rend_desc.get_x_res() << endl; + } + + if (job.canvas_info_all || job.canvas_info_y_res) + { + cout << endl << "# " << _("Y Resolution") << endl; + cout << "y_res" << "=" << rend_desc.get_y_res() << endl; + } + + if (job.canvas_info_all || job.canvas_info_span) + { + cout << endl << "# " << _("Diagonal Image Span") << endl; + cout << "span" << "=" << rend_desc.get_span() << endl; + } + + if (job.canvas_info_all) + cout << endl; + + if (job.canvas_info_all || job.canvas_info_interlaced) + { + cout << endl << "# " << _("Interlaced") << endl; + cout << "interlaced" << "=" << rend_desc.get_interlaced() << endl; + } + + if (job.canvas_info_all || job.canvas_info_antialias) + { + cout << endl << "# " << _("Antialias") << endl; + cout << "antialias" << "=" << rend_desc.get_antialias() << endl; + } + + if (job.canvas_info_all || job.canvas_info_clamp) + { + cout << endl << "# " << _("Clamp") << endl; + cout << "clamp" << "=" << rend_desc.get_clamp() << endl; + } + + if (job.canvas_info_all || job.canvas_info_flags) + { + cout << endl << "# " << _("Flags") << endl; + cout << "flags" << "=" << rend_desc.get_flags() << endl; + } + + if (job.canvas_info_all || job.canvas_info_focus) + { + cout << endl << "# " << _("Focus") << endl; + cout << "focus" << "=" << rend_desc.get_focus()[0] + << " " << rend_desc.get_focus()[1] << endl; + } + + if (job.canvas_info_all || job.canvas_info_bg_color) + { + cout << endl << "# " << _("Background Color") << endl; + cout << "bg_color" << "=" << rend_desc.get_bg_color().get_string().c_str() << endl; + } + + if (job.canvas_info_all) + cout << endl; + + if (job.canvas_info_all || job.canvas_info_metadata) + { + std::list keys(canvas->get_meta_data_keys()); + cout << endl << "# " << _("Metadata") << endl; + for (std::list::iterator iter = keys.begin(); iter != keys.end(); iter++) + cout << *iter << "=" << canvas->get_meta_data(*iter) << endl; + } +} + /* === M E T H O D S ======================================================= */ /* === E N T R Y P O I N T ================================================= */ @@ -932,6 +1188,8 @@ int main(int argc, char *argv[]) extract_list_canvases(imageargs, list_canvases); job_list.front().list_canvases = list_canvases; + extract_canvas_info(imageargs, job_list.front()); + job_list.front().root->set_time(0); string canvasid; @@ -1134,6 +1392,11 @@ int main(int argc, char *argv[]) list_child_canvases(job_list.front().filename + "#", job_list.front().canvas); cerr << endl; } + else if (job_list.front().canvas_info) + { + list_canvas_info(job_list.front()); + cerr << endl; + } else { VERBOSE_OUT(1)<<_("Rendering...")<