{"id":32625,"date":"2020-06-20T17:03:00","date_gmt":"2020-06-20T17:03:00","guid":{"rendered":"https:\/\/foojay.io\/?p=32625"},"modified":"2021-08-23T12:24:46","modified_gmt":"2021-08-23T12:24:46","slug":"how-does-java-handle-different-images-and-colorspaces-part-1","status":"publish","type":"post","link":"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/","title":{"rendered":"How does Java handle different Images and ColorSpaces \u2013 Part 1"},"content":{"rendered":"\n<p>One of the attractions of Java is the way it abstracts and simplifies many programming constructs. In place of Tiffs, PNGs, JPEGs and other Image formats, you get a simple BufferedImage object. ImageIO and other third-party libraries such as our own&nbsp;<a target=\"_blank\" href=\"https:\/\/www.idrsolutions.com\/jdeli\/\">JDeli image library<\/a>&nbsp;provide methods to read and write a BufferedImage.<\/p>\n\n\n<p>We have spent a lot of time working with different images formats in the process of writing the&nbsp;<a target=\"_blank\" href=\"https:\/\/www.idrsolutions.com\/jdeli\/\">JDeli<\/a>&nbsp;Image library as a&nbsp;<a target=\"_blank\" href=\"https:\/\/www.idrsolutions.com\/jdeli\/imageio-replacement\/\">replacement for&nbsp; ImageIO<\/a>&nbsp;and the aim of this series is to share that knowledge to a wider audience.<\/p>\n\n\n<p>Java makes images simple to use. You can work with a BufferedImage and just load or save this to any supported image file format. A BufferedImage includes lots of functionality which allows you to render and process the image, with all the complexity and implementation hidden by Java. A BufferedImage can even be used as a Graphics2D canvas which can be drawn on. Here is some example code.<\/p>\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/load image with ImageIO or JDeli\nBufferedImage image = ImageIO.read(new File(\"image.png\"));\nBufferedImage image = JDeli.read(new File(\"image.png\"));\n\n\/\/draw a red diagonal line on it\nGraphics2D g2 = image.createGraphics();\ng2.setColor(Color.red);\ng2.drawLine(0, 0, image.getWidth(), image.getHeight());\n\n\/\/save image with ImageIO or JDeli\nImageIO.write(image, \"PNG\", new File(\"image.png\"));\nJDeli.write(image, \"PNG\", new File(\"image.png\"));<\/pre>\n\n\n<p>While Java removes a lot of Image complexity, it is worth understanding in more detail how images work. In this series of articles, we will be diving deep into how BufferedImage provides this abstraction, how different types of images work and how you can access the low-level Image data.<\/p>\n\n\n<p>See you next time when we will look at ColorSpaces.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java makes images simple to use. You can work with a BufferedImage and just load or save this to any supported image file format. A BufferedImage includes lots of functionality which allows you to render and process the image, with all the complexity and implementation hidden by Java. A BufferedImage can even be used as a Graphics2D canvas which can be drawn on. Here is some example code.<\/p>\n<p>While Java removes a lot of Image complexity, it is worth understanding in more detail how images work. In this series of articles, we will be diving deep into how BufferedImage provides this abstraction, how different types of images work and how you can access the low-level Image data.<\/p>\n","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[33,35],"class_list":["post-32625","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-java","tag-openjdk"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>foojay \u2013 a place for friends of OpenJDK<\/title>\n<meta name=\"description\" content=\"foojay is the place for all OpenJDK Update Release Information. Learn More.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"foojay \u2013 a place for friends of OpenJDK\" \/>\n<meta property=\"og:description\" content=\"foojay is the place for all OpenJDK Update Release Information. Learn More.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/\" \/>\n<meta property=\"og:site_name\" content=\"foojay\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-20T17:03:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-23T12:24:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/foojay.io\/wp-content\/uploads\/2020\/04\/Favicon-3-2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"384\" \/>\n\t<meta property=\"og:image:height\" content=\"384\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Mark Stephens\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mark Stephens\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/how-does-java-handle-different-images-and-colorspaces-part-1\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/how-does-java-handle-different-images-and-colorspaces-part-1\\\/\"},\"author\":{\"name\":\"Mark Stephens\",\"@id\":\"https:\\\/\\\/foojay.io\\\/#\\\/schema\\\/person\\\/750f1f5bc582e0c9728bf8f28e9461b7\"},\"headline\":\"How does Java handle different Images and ColorSpaces \u2013 Part 1\",\"datePublished\":\"2020-06-20T17:03:00+00:00\",\"dateModified\":\"2021-08-23T12:24:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/how-does-java-handle-different-images-and-colorspaces-part-1\\\/\"},\"wordCount\":237,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/#organization\"},\"keywords\":[\"Java\",\"OpenJDK\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/foojay.io\\\/today\\\/how-does-java-handle-different-images-and-colorspaces-part-1\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/how-does-java-handle-different-images-and-colorspaces-part-1\\\/\",\"url\":\"https:\\\/\\\/foojay.io\\\/today\\\/how-does-java-handle-different-images-and-colorspaces-part-1\\\/\",\"name\":\"foojay \u2013 a place for friends of OpenJDK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/#website\"},\"datePublished\":\"2020-06-20T17:03:00+00:00\",\"dateModified\":\"2021-08-23T12:24:46+00:00\",\"description\":\"foojay is the place for all OpenJDK Update Release Information. Learn More.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/how-does-java-handle-different-images-and-colorspaces-part-1\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/foojay.io\\\/today\\\/how-does-java-handle-different-images-and-colorspaces-part-1\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/foojay.io\\\/today\\\/how-does-java-handle-different-images-and-colorspaces-part-1\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/foojay.io\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How does Java handle different Images and ColorSpaces \u2013 Part 1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/foojay.io\\\/#website\",\"url\":\"https:\\\/\\\/foojay.io\\\/\",\"name\":\"foojay\",\"description\":\"a place for friends of OpenJDK\",\"publisher\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/foojay.io\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/foojay.io\\\/#organization\",\"name\":\"foojay\",\"url\":\"https:\\\/\\\/foojay.io\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/foojay.io\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/foojay.io\\\/wp-content\\\/uploads\\\/2020\\\/04\\\/cropped-Favicon.png\",\"contentUrl\":\"https:\\\/\\\/foojay.io\\\/wp-content\\\/uploads\\\/2020\\\/04\\\/cropped-Favicon.png\",\"width\":512,\"height\":512,\"caption\":\"foojay\"},\"image\":{\"@id\":\"https:\\\/\\\/foojay.io\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/foojay2020\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/foojay.io\\\/#\\\/schema\\\/person\\\/750f1f5bc582e0c9728bf8f28e9461b7\",\"name\":\"Mark Stephens\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9ac75725e39c6001c43782366fe8c4a255662ed2db3a1582012d9f23ec1f60e6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9ac75725e39c6001c43782366fe8c4a255662ed2db3a1582012d9f23ec1f60e6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9ac75725e39c6001c43782366fe8c4a255662ed2db3a1582012d9f23ec1f60e6?s=96&d=mm&r=g\",\"caption\":\"Mark Stephens\"},\"description\":\"Entrepreneur and Java software developer, founder and CEO of IDRsolutions\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/mnstephens\\\/\",\"https:\\\/\\\/x.com\\\/markee174\"],\"url\":\"https:\\\/\\\/foojay.io\\\/today\\\/author\\\/mark-stephens\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"foojay \u2013 a place for friends of OpenJDK","description":"foojay is the place for all OpenJDK Update Release Information. Learn More.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/","og_locale":"en_US","og_type":"article","og_title":"foojay \u2013 a place for friends of OpenJDK","og_description":"foojay is the place for all OpenJDK Update Release Information. Learn More.","og_url":"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/","og_site_name":"foojay","article_published_time":"2020-06-20T17:03:00+00:00","article_modified_time":"2021-08-23T12:24:46+00:00","og_image":[{"width":384,"height":384,"url":"https:\/\/foojay.io\/wp-content\/uploads\/2020\/04\/Favicon-3-2.png","type":"image\/png"}],"author":"Mark Stephens","twitter_misc":{"Written by":"Mark Stephens","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/#article","isPartOf":{"@id":"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/"},"author":{"name":"Mark Stephens","@id":"https:\/\/foojay.io\/#\/schema\/person\/750f1f5bc582e0c9728bf8f28e9461b7"},"headline":"How does Java handle different Images and ColorSpaces \u2013 Part 1","datePublished":"2020-06-20T17:03:00+00:00","dateModified":"2021-08-23T12:24:46+00:00","mainEntityOfPage":{"@id":"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/"},"wordCount":237,"commentCount":0,"publisher":{"@id":"https:\/\/foojay.io\/#organization"},"keywords":["Java","OpenJDK"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/","url":"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/","name":"foojay \u2013 a place for friends of OpenJDK","isPartOf":{"@id":"https:\/\/foojay.io\/#website"},"datePublished":"2020-06-20T17:03:00+00:00","dateModified":"2021-08-23T12:24:46+00:00","description":"foojay is the place for all OpenJDK Update Release Information. Learn More.","breadcrumb":{"@id":"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/foojay.io\/today\/how-does-java-handle-different-images-and-colorspaces-part-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/foojay.io\/"},{"@type":"ListItem","position":2,"name":"How does Java handle different Images and ColorSpaces \u2013 Part 1"}]},{"@type":"WebSite","@id":"https:\/\/foojay.io\/#website","url":"https:\/\/foojay.io\/","name":"foojay","description":"a place for friends of OpenJDK","publisher":{"@id":"https:\/\/foojay.io\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/foojay.io\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/foojay.io\/#organization","name":"foojay","url":"https:\/\/foojay.io\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/foojay.io\/#\/schema\/logo\/image\/","url":"https:\/\/foojay.io\/wp-content\/uploads\/2020\/04\/cropped-Favicon.png","contentUrl":"https:\/\/foojay.io\/wp-content\/uploads\/2020\/04\/cropped-Favicon.png","width":512,"height":512,"caption":"foojay"},"image":{"@id":"https:\/\/foojay.io\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/foojay2020"]},{"@type":"Person","@id":"https:\/\/foojay.io\/#\/schema\/person\/750f1f5bc582e0c9728bf8f28e9461b7","name":"Mark Stephens","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9ac75725e39c6001c43782366fe8c4a255662ed2db3a1582012d9f23ec1f60e6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9ac75725e39c6001c43782366fe8c4a255662ed2db3a1582012d9f23ec1f60e6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9ac75725e39c6001c43782366fe8c4a255662ed2db3a1582012d9f23ec1f60e6?s=96&d=mm&r=g","caption":"Mark Stephens"},"description":"Entrepreneur and Java software developer, founder and CEO of IDRsolutions","sameAs":["https:\/\/www.linkedin.com\/in\/mnstephens\/","https:\/\/x.com\/markee174"],"url":"https:\/\/foojay.io\/today\/author\/mark-stephens\/"}]}},"_links":{"self":[{"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/posts\/32625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/comments?post=32625"}],"version-history":[{"count":0,"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/posts\/32625\/revisions"}],"wp:attachment":[{"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/media?parent=32625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/categories?post=32625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/foojay.io\/wp-json\/wp\/v2\/tags?post=32625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}