{"id":10759,"date":"2014-06-16T00:11:50","date_gmt":"2014-06-16T04:11:50","guid":{"rendered":"http:\/\/scruss.com\/blog\/?p=10759"},"modified":"2016-12-12T18:43:01","modified_gmt":"2016-12-12T23:43:01","slug":"jpeg-2000-on-ubuntu-without-anyone-getting-stabbed","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2014\/06\/16\/jpeg-2000-on-ubuntu-without-anyone-getting-stabbed\/","title":{"rendered":"JPEG 2000 on Ubuntu \u00e2\u20ac\u201d without anyone getting stabbed"},"content":{"rendered":"<p><span style=\"color: #ff0000;\"><em><strong>Aargh<\/strong>! Ubuntu 16.10 has decided that ImageMagick doesn&#8217;t need JPEG 2000 support, and will quietly (and very very wrongly) write JP2s as JPEG.<\/em><\/span><\/p>\n<p>(<strong>NB<\/strong>: <em>JPEG 2000 images <del>still<\/del> maybe crash Ubuntu&#8217;s file browser in 14.10<\/em>. <em>My old installation didn&#8217;t like them, but my reinstall seems quite happy. Go figure.<\/em>)<\/p>\n<p><a href=\"http:\/\/www.jpeg.org\/jpeg2000\/\">JPEG 2000<\/a> is a great image file format: well-defined, and able to store high quality photographic data in a very small space. It truly is the JPEG of the 2000s \u00e2\u20ac\u201d except for its dismal support under Ubuntu.<\/p>\n<p>The problem is the <a href=\"https:\/\/en.wikipedia.org\/wiki\/JPEG_2000#Legal_status\">patents<\/a>. An open library has been a long time coming, and lots of Linux software is built without JP2 support. This helped keep it away from my desktop.<\/p>\n<p>Under Ubuntu 14.04, here&#8217;s what does and doesn&#8217;t support JP2 files:<\/p>\n<ul>\n<li><strong>Gimp<\/strong> \u00e2\u20ac\u201d not supported. It appears to have a non-functioning plugin that tries to read the file, then gives up. This is annoying, as Gimp is defined as the system default viewer for JPEG 2000.<\/li>\n<li><strong>Image Viewer<\/strong> \u00e2\u20ac\u201d does support JP2, but occasionally mis-renders pages. To make this the default, right-click on a JP2 file, and select <em>Open with \u00e2\u2020\u2019 Other Application \u00e2\u20ac\u00a6<\/em>, then choose <strong>Image Viewer<\/strong>. It should work from then onwards.<\/li>\n<li><strong>Document Viewer<\/strong> \u00e2\u20ac\u201d a bit rough when looking at JPEG 2000-encoded PDFs. Very slow, too.<\/li>\n<li><strong><a href=\"http:\/\/www.graphicsmagick.org\/\">GraphicsMagick<\/a><\/strong> \u00e2\u20ac\u201d seems to be the most painless way of converting graphics files to JPEG 2000. My preferred method of invoking it is:<br \/>\n<tt>gm convert -define 'jp2:rate=0.008' in.png out.jp2<\/tt><br \/>\nThe <em>rate<\/em> option should be a small number; the smaller, the greater the compression, and the worse the image quality.<\/li>\n<li><strong><a href=\"http:\/\/www.openjpeg.org\/\">OpenJPEG<\/a><\/strong> \u00e2\u20ac\u201d provides the <tt>image_to_j2k<\/tt> and <tt>j2k_to_image<\/tt> tools. Far more picky about input formats than it should be, and often fails on seemingly perfect input.<\/li>\n<li><strong><a href=\"https:\/\/github.com\/josch\/img2pdf\">img2pdf<\/a><\/strong> \u00e2\u20ac\u201d (<em>built from source<\/em>)\u00c2\u00a0 is a tiny gem of a package. All it does is wrap various image formats into a PDF file. It doesn&#8217;t modify the image data in any way, so with a bit of ingenuity (and <a href=\"http:\/\/www.pdflabs.com\/docs\/pdftk-man-page\/\">pdftk<\/a>) you can use PDF as a true metafile archive. You can view the content on any platform, but get the source images out bit-for-bit perfect. We used to call files which could contain files <em>metafiles<\/em>, but that stopped being popular when TIFF started to be a baroque travesty of an image container back in the mid-1990s.<\/li>\n<li><strong><a href=\"http:\/\/poppler.freedesktop.org\/\">poppler<\/a><\/strong> \u00e2\u20ac\u201d (<em>for full features, build from source<\/em>) has a tool, <tt>pdfimages<\/tt>, which can extract embedded image files from PDFs. Some of the metadata might get lost, but all of the image bits come through.<\/li>\n<\/ul>\n<p>Since JPEG 2000 isn&#8217;t included in web browsers (<em>grar<\/em>), I&#8217;ve embedded a sample scanned JPEG into a PDF, and added a series of progressively more compressed JPEG 2000 versions: <a href=\"http:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2014\/06\/JPEG-2000Booklet.pdf\">JPEG-2000Booklet<\/a> [PDF].\u00c2\u00a0 The booklet has notes showing the byte size of each page. The image still looks pretty good at 8% of the original file size!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Aargh! Ubuntu 16.10 has decided that ImageMagick doesn&#8217;t need JPEG 2000 support, and will quietly (and very very wrongly) write JP2s as JPEG. (NB: JPEG 2000 images still maybe crash Ubuntu&#8217;s file browser in 14.10. My old installation didn&#8217;t like them, but my reinstall seems quite happy. Go figure.) JPEG 2000 is a great image [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[48,2812,2810,2811,2809,2813,765,2395],"class_list":["post-10759","post","type-post","status-publish","format-standard","hentry","category-computers-suck","tag-archive","tag-img2pdf","tag-jp2","tag-jp2k","tag-jpeg2000","tag-metafile","tag-pdf","tag-pdftk"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-2Nx","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/10759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=10759"}],"version-history":[{"count":8,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/10759\/revisions"}],"predecessor-version":[{"id":13591,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/10759\/revisions\/13591"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=10759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=10759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=10759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}