13
$\begingroup$

I need to import 40 images from a folder into Mathematica, and I find the new version imports them slower than previous versions.

Does anyone else experience the same?

$Version
animals = Import["Animals/*"]; // AbsoluteTiming

enter image description here

$\endgroup$
  • 4
    $\begingroup$ I mean, isn't the question, "do images import more slowly in v11 than they do in previous version?" with the implied question, "is there a way to revert to the old behavior?" $\endgroup$ – Ben Kalziqi Aug 10 '16 at 7:21
9
$\begingroup$

This is a long comment. I can reproduce the problem on OS X with version 11.0.0. I have not found a fix. I know that image import was changed in version 11 for all common formats and that a lot of metadata is now imported. This metadata is also stored in the Image objects as the MetaInformation option (can be retrieved with Options). I don't know if the metadata import has anything to do with the performance regression (it may not be related at all).

Please contact Wolfram Support and let them know about this.

Here's a speed test on 40 JPEG images which I have in three different resolutions:

Version 11.0

dir = "full";

ImageDimensions@Import@First@FileNames[dir <> "/*.jpg"]
(* {2700, 1800} *)

Import[#, "Image"] & /@ 
   FileNames[dir <> "/*.jpg"]; // AbsoluteTiming
(* {5.47223, Null} *)

dir = "medium";

ImageDimensions@Import@First@FileNames[dir <> "/*.jpg"]
(* {1620, 1080} *)

Import[#, "Image"] & /@ 
   FileNames[dir <> "/*.jpg"]; // AbsoluteTiming
(* {3.31634, Null} *)

dir = "thumbnail"
(* "thumbnail" *)

ImageDimensions@Import@First@FileNames[dir <> "/*.jpg"]
(* {640, 427} *)

Import[#, "Image"] & /@ 
   FileNames[dir <> "/*.jpg"]; // AbsoluteTiming
(* {2.29118, Null} *)

Version 10.4.1

dir = "full";

ImageDimensions@Import@First@FileNames[dir <> "/*.jpg"]
(* {2700, 1800} *)

Import[#, "Image"] & /@ 
   FileNames[dir <> "/*.jpg"]; // AbsoluteTiming
(* {5.13607, Null} *)

dir = "medium";

ImageDimensions@Import@First@FileNames[dir <> "/*.jpg"]
(* {1620, 1080} *)

Import[#, "Image"] & /@ 
   FileNames[dir <> "/*.jpg"]; // AbsoluteTiming
(* {2.26651, Null} *)

dir = "thumbnail"
(* "thumbnail" *)

ImageDimensions@Import@First@FileNames[dir <> "/*.jpg"]
(* {640, 427} *)

Import[#, "Image"] & /@ 
   FileNames[dir <> "/*.jpg"]; // AbsoluteTiming
(* {1.15178, Null} *)

Version 9.0.1

Notice that the timing depends on the image size and for large images version 9 is slower than both version 10 and version 11.

dir = "full";

ImageDimensions@Import@First@FileNames[dir <> "/*.jpg"]
(* {2700, 1800} *)

Import[#, "Image"] & /@ 
   FileNames[dir <> "/*.jpg"]; // AbsoluteTiming
(* {9.187798, Null} *)

dir = "medium";

ImageDimensions@Import@First@FileNames[dir <> "/*.jpg"]
(* {1620, 1080} *)

Import[#, "Image"] & /@ 
   FileNames[dir <> "/*.jpg"]; // AbsoluteTiming
(* {3.503787, Null} *)

dir = "thumbnail"
(* "thumbnail" *)

ImageDimensions@Import@First@FileNames[dir <> "/*.jpg"]
(* {640, 427} *)

Import[#, "Image"] & /@ 
   FileNames[dir <> "/*.jpg"]; // AbsoluteTiming
(* {1.006552, Null} *)
$\endgroup$
10
$\begingroup$

Yes, the metadata import causes the performance regression in version 11.0. If you don't need Exif, IPTC and XMP metadata, then you can disable it using IncludeMetaInformation option:

In[1]:= $Version
Out[1]= "11.0.0 for Microsoft Windows (64-bit) (July 28, 2016)"

 In[2]:= RepeatedTiming[images = Import["f:\\SampleImages\*"];]
Out[2]= {0.380, Null}

In[3]:= RepeatedTiming[ images = Import["f:\\SampleImages\*", IncludeMetaInformation -> None];]
Out[3]= {0.19, Null}
$\endgroup$
  • 1
    $\begingroup$ Thank you for this; I import a lot of PNGs for analysis for my work, and this is a huge time saver. $\endgroup$ – Ben Kalziqi Sep 27 '16 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.