0
$\begingroup$

How can I apply a particular image function (such as ImageTrim) to an entire folder of images and then save/export those edited (trimmed) images to a new folder?

$\endgroup$

closed as off-topic by Alexey Popkov, Wjx, glS, gwr, m_goldberg Mar 26 '17 at 15:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Alexey Popkov, Wjx, glS, gwr, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ What have you tried? This seems fairly straightfoward. Iterate with Do or Scan, use Import/Export, and look up the file name manipulation functions. for constructing the new file name from the old one. When everything is working, parallelize with ParallelDo. $\endgroup$ – Szabolcs Mar 23 '17 at 21:01
  • $\begingroup$ Thank you! will try that. Cheers $\endgroup$ – Sunny Mar 23 '17 at 21:51
3
$\begingroup$

You may try like this: for version: 11.1

get your folder files:

   path = "C:\\Users\\sunny";
   SetDirectory[path]
   files = FileNames[]

lets create your files:

   im = Import["ExampleData/spikey.tiff"]

enter image description here

   files = {im, im, im, im};

then image trim entire folder of images:

 img=ImageTrim[files[[#]], {{30, 30}, {90, 90}}] & /@ Range[Length[files]]

enter image description here

Export files to folder named trim:

   Export["C:\\Users\\sunny\\Desktop\\trim\\" <> "new_" <> ToString[#] <> 
            ".png", img[[#]]] & /@ Range[Length@files]
$\endgroup$

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