{"id":1884,"date":"2011-03-09T14:10:00","date_gmt":"2011-03-09T14:10:00","guid":{"rendered":"http:\/\/www.b.shuttle.de\/hayek\/Hayek\/Jochen\/wp\/blog-en\/2011\/03\/09\/how-to-copy-a-rectangle-region-from-an-image-file-cropping\/"},"modified":"2020-08-20T11:05:25","modified_gmt":"2020-08-20T09:05:25","slug":"how-to-copy-a-rectangle-region-from-an-image-file-cropping","status":"publish","type":"post","link":"https:\/\/wp.jochen.hayek.name\/blog-en\/2011\/03\/09\/how-to-copy-a-rectangle-region-from-an-image-file-cropping\/","title":{"rendered":"how to copy a rectangle region from an image file? (&#8220;cropping&#8221;)"},"content":{"rendered":"<p>\t\t\t\tMy original source files\u00a0are PDF files, but I already converted them to PNG using Ghostscript.<\/p>\n<p>I was thinking of <i><a href=\"http:\/\/www.imagemagick.org\/\">ImageMagick<\/a><\/i> \u2026<\/p>\n<p>I came across <a href=\"http:\/\/photobatch.stani.be\/\"><i>phatch<\/i><\/a>, I read of it <a href=\"http:\/\/www.heise.de\/artikel-archiv\/ct\/2010\/23\/64_kiosk\">here<\/a>. It&#8217;s a GUI, that helps running <i>ImageMagick<\/i> with certain operations in a batch. It came with a lot of dependencies on other packages. I tried to fullfil some of of them, eventually I gave up. If I very sure, that <i>phatch<\/i> was the way to go, that dependency hell wouldn&#8217;t be a dead end. Spending time on getting phatch to run was a dead end for me.<\/p>\n<p>There is a book on <a href=\"https:\/\/www.packtpub.com\/imagemagick-tricks\/book\">ImageMagick at PackPub<\/a>, there is also <a href=\"http:\/\/www.apress.com\/book\/view\/9781590595909\">one at Apress<\/a>. I bought both of them as PDFs. That was the key to the success. I found nice examples, and I was able to apply some easy recipe to my task.<\/p>\n<p><span>$ convert orig.png -crop <i>geometry<\/i> new.png<\/span><\/p>\n<div>\nActually <a href=\"http:\/\/www.imagemagick.org\/Usage\/crop\/\">the recommendation<\/a> says to use &#8220;<span>+repage<\/span>&#8220;, in order to not confuse certain software:<\/div>\n<div>\n<\/div>\n<div>\n<span>$ convert orig.png -crop <i>geometry<\/i> +repage new.png<\/span><\/div>\n<div>\n<\/div>\n<div>\nWithout &#8220;<span>+repage<\/span>&#8221; the file stores the displacement of the segment wrt. the original image, which comes in quite handy, but \u2026 certain software gets confused, eg. when I loaded one such new image into GIMP, GIMP displayed the displacement and presented me rubbish.<\/div>\n<div>\n<\/div>\n<p>There is a fork of ImageMagick called <a href=\"http:\/\/www.graphicsmagick.org\/\">GraphicsMagick<\/a>. Pretty fast, but you may come across features of ImageMagick, that GraphicsMagick doesn&#8217;t know.<\/p>\n<p>\u2026\t\t\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My original source files\u00a0are PDF files, but I already converted them to PNG using Ghostscript. I was thinking of ImageMagick \u2026 I came across phatch, I read of it here. It&#8217;s a GUI, that helps running ImageMagick with certain operations in a batch. It came with a lot of dependencies on other packages. I tried [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_share_on_mastodon":"0"},"categories":[167,666],"tags":[],"class_list":["post-1884","post","type-post","status-publish","format-standard","hentry","category-gimp","category-uncategorized"],"share_on_mastodon":{"url":"","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paO0kP-uo","jetpack_likes_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/1884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/comments?post=1884"}],"version-history":[{"count":1,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/1884\/revisions"}],"predecessor-version":[{"id":11215,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/1884\/revisions\/11215"}],"wp:attachment":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/media?parent=1884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/categories?post=1884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/tags?post=1884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}