# How to import many Images in Mathematica?

I have 150 images that I want to import into the Mathematica, and process. I use this code but I get errors. I ran the example for three images.

imgdir = FileNameJoin[{NotebookDirectory[], "Flow pic"}];

{IR, R, G} =
Import[FileNameJoin[{imgdir, "le-" <> ToString[#] <> ".jpg"}],
"Data"] & /@ {3, 2, 1};

image = Map[ImageTake[#, {50, 630}, {499, 600}] &,
Map[ImageResize[#, {900, 650}] &, {IR, R, G}]]


Either removing the "Data" format argument or using "JPEG" instead should do it.

Here is a short example based on the original code.

imgdir = FileNameJoin[{NotebookDirectory[], "Flow pic"}];
(*Export three images for testing purpose*)
SeedRandom[42];
images = ExampleData /@ RandomChoice[ExampleData["TestImage"], 3]
Export[FileNameJoin[{imgdir, "le-" <> ToString[#] <> ".jpg"}],
images[[#]], "JPEG"] & /@ Range[3];
FileSystemMap[FileSize, imgdir]
(*Output*)


(*Using Import function with "JPEG" fmt argument*)
imagesA = Import[FileNameJoin[{imgdir, "le-" <> ToString[#] <> ".jpg"}], "JPEG"] & /@ {3, 2, 1};
Map[ImageTake[#, {50, 630}, {499, 600}] &, Map[ImageResize[#, {900, 650}] &, imagesA]]

(*Using Import function w/o fmt argument*)
imagesB = Import[FileNameJoin[{imgdir, "le-" <> ToString[#] <> ".jpg"}]] & /@ {3, 2, 1};
Map[ImageTake[#, {50, 630}, {499, 600}] &, Map[ImageResize[#, {900, 650}] &, imagesB]]
(*Output*)


• However correct it is, this reads like a comment, and not as an answer worth accepting. Probably you could flesh it out more. Sep 8, 2023 at 12:07

Try this....

Test images

imgdir = FileNameJoin[{NotebookDirectory[], "Flow pic"}]
imgdata = Import[FileNameJoin[{imgdir,"le-" <> ToString[#] <> ".jpg"}]] & /@ {3, 2, 1};

image = ImageTake[#, {50, 630}, {499, 600}] & /@ ImageResize[#, {900, 650}] & /@ imgdata


• Tank you, But the last line related to image processing does not work properly Sep 8, 2023 at 4:14