{"id":16493,"date":"2009-10-05T10:00:00","date_gmt":"2009-10-05T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2009\/10\/05\/why-doesnt-the-mail-image-resizer-check-the-image-size-before-offering-to-resize\/"},"modified":"2009-10-05T10:00:00","modified_gmt":"2009-10-05T10:00:00","slug":"why-doesnt-the-mail-image-resizer-check-the-image-size-before-offering-to-resize","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20091005-00\/?p=16493","title":{"rendered":"Why doesn&#039;t the mail image resizer check the image size before offering to resize?"},"content":{"rendered":"<p>\nCommenter Igor\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/pages\/407234.aspx#669781\">\nlambastes the image resizer dialog that appears when you select\nSend To Mail Recipient<\/a>.\n(And people think I&#8217;m the one with the social skills of a thermonuclear\ndevice.)\nThis dialog pisses him off so much,\n<a HREf=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2007\/07\/09\/3769001.aspx#3818035\">\nhe complained about it again<\/a>.\n<\/p>\n<p>\nThe root of the diatribe appears to be that the image resizer dialog\nappears, even if it turns out the resizer won&#8217;t do anything.\nFor example, the resizer dialog appears even if the images are\nalready small,\nor if the files have a .jpg extension but aren&#8217;t actually JPG images,\nWhy is it so idiotic that it fails to\ncheck these simple things before offering to do its work?\n<\/p>\n<p>\nBecause checking these simple things before showing the dialog\nis even more idiotic.\n<\/p>\n<p>\nOne of the grave errors when doing work with files is accessing the file\nbefore the user asks for it.\nThis is a grave error because accessing the file can take an\nexcruciatingly long time\nif the file is stored on a server halfway across the\nworld over a slow network connection,\nor if the file has been\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2005\/11\/28\/497442.aspx\">\narchived to tape<\/a>.\n<\/p>\n<p>\nThis particular code path is sensitive to the file access time\nbecause the user has just picked a menu item.\nSuppose the dialog box went ahead and opened the files to confirm that,\nyes, they really are images, and yes, the dimensions of the image\nare larger than what the dialog offers to resize them to.\nYou select 1000 small images on a slow server, right-click them,\nand pick Send To&#8230; Mail Recipient.\n<\/p>\n<p>\nThen you wait 30 minutes while the dialog box goes off and does\nsomething like this:\n<\/p>\n<pre>\nshouldOfferResize = false;\nforeach (file in selection)\n{\n  if (file.IsJPGThatIsNotCorrupted() &amp;&amp;\n      file.IsWorthResizing()) {\n    shouldOfferResize = true;\n    break; \/\/ can early-out the loop once we find something\n  }\n}\n<\/pre>\n<p>\nOpening each file, parsing it to verify that it is a valid JPG\nfile that decodes without error, and extracting its dimensions\ntakes, say, 2 seconds per file.\n(The file is slow to access, say, it&#8217;s on a network server or\non a slow medium like a CD-ROM or a tape drive.\nOr the file is large and it takes 2 seconds to read it off the disk\nand parse it to verify that there are no decoding errors.)\n<\/p>\n<p>\nAfter about 15 seconds with no response, you give up and say\n&#8220;I hate computers.&#8221;\nand go off and do something else,\nfrustrated that you were unable to email your photos.\n<\/p>\n<p>\nAnd then in the middle of working in your word processor,\nthis dialog box suddenly appears:\n&#8220;Windows can resize the pictures you send in e-mail\nso that they transfer faster and are easier to view by the recipient.&#8221;\n<\/p>\n<p>\nGee thanks, Windows, for finally getting around to asking me\nabout that thing I wanted to do <i>a half hour ago<\/i>.\n<\/p>\n<p>\nIdiot.\n<\/p>\n<p>\nAnd then when you click No, Windows has to go and decode the files\na second time in order to print them.\n(Unless Igor&#8217;s recommendation is to cache the decoded bits from the first\npass. Then you&#8217;d complain that\nselecting 1000 files and clicking &#8220;Send To&#8230;\nMail Recipient&#8221;\ncauses your computer to run out of memory.\nAs Igor is fond of saying when insulting the Windows team:\n&#8220;Looks like this feature was designed without any adult supervision.&#8221;)\n<\/p>\n<p>\n<b>Sidebar<\/b>:\nA good fraction of these blog entries are just elaborations on\nvery simple concepts.\nWhen I toss an entry onto the &#8220;I should blog this&#8221; pile,\nit usually gets a short remark of five to ten words\nwhich captures what I want to say.\nThen when it floats to the head of the queue,\nI expand those ten words into a 300-word entry.\nThe short version of today&#8217;s entry:\n&#8220;That would hit the disk.&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Commenter Igor lambastes the image resizer dialog that appears when you select Send To Mail Recipient. (And people think I&#8217;m the one with the social skills of a thermonuclear device.) This dialog pisses him off so much, he complained about it again. The root of the diatribe appears to be that the image resizer dialog [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-16493","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>Commenter Igor lambastes the image resizer dialog that appears when you select Send To Mail Recipient. (And people think I&#8217;m the one with the social skills of a thermonuclear device.) This dialog pisses him off so much, he complained about it again. The root of the diatribe appears to be that the image resizer dialog [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/16493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=16493"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/16493\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=16493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=16493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=16493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}