Best way to access image files to improve performance

I am using a graphicmagick.exe (command tool) to convert the file from one format to another format: In that, I used to pass input path and output path for conversion as aruguments. Now I am looping a directory using foreach and passing the input file one by one and converting to another format.

But it affects the performance. Is there any better way to increase the performance? Please suggest me.

-------------Problems Reply------------

Use Parallel class (ForEach or For).

Parallel.ForEach(files, file =>
// do something with file

In that case all your processor cores will be loaded. Otherwise just one. But remember, that you code inside Parallel blocks must be thread-safe and not to block each-other.


I think your code executes the application on each for. So, it's very expensive. The application has options for multiple file handling. Check first that, instead of a code that execute the application, for every file. Is different to start one process and apply changes on the image than starting one process per file.

If you still need to execute on C#, change your code to use Parallel.Foreach instead of foreach and check if there is a gain in the execution. Try with a sample, maybe 50-100 files in a directory and check execution time between both implementations.

Greetings and good luck!

Category:c# Views:4 Time:2018-08-06

Related post

  • Best way to access images outside of a project? 2011-12-12

    I currently have several WPF projects that need to access a folder of images. What would the best way be to allow the projects to have access to the same images folder w/out duplication? example structure: Root Folder Images Project 1 Project 2 Proje

  • Best way of saving image file and to save memory 2011-08-18

    In my program i am creating some big pictures (Image objects), and saving them to disk. Then I add them to a list List<Image> but after saving 50 pictures and adding them as Image objects to my imageList it eats up a loooooot of memory. I tried

  • Best way to handle images in Java 2011-07-30

    I will develop a Java application that uses some image processing algorithms. I have done some image processing applications using C++. I'm currently using BufferedImage object to save data from images but I'm wondering if there is a better way to ha

  • What's the best way to paste images/ diagrams from PDF file into MS Word 2010? 2013-08-17

    Hello What's the best way to copy images/ diagrams from PDF files and paste into MS Word 2010? Thanks. --------------Solutions------------- I believe that there is really only one way, though you may want to make use of the Ctrl+C and Ctrl+V shortcut

  • Best way to preload images 2011-05-27

    What's the best way to preload images? I'm trying to create an image tab that has around 59 png images. Here's the code I have so far: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" ""> <htm

  • Python - Best way to read a file and break out the lines by a delimeter 2011-10-13

    What is the best way to read a file and break out the lines by a delimeter. Data returned should be a list of tuples. Can this method be beaten? Can this be done faster/using less memory? def readfile(filepath, delim): with open(filepath, 'r') as f:

  • Is a custom module the best way to access an external API in Drupal? 2008-10-13

    I'm new to extending Drupal, though I've done similar kinds of things for other CMSes. Anyone care to share opinions on the best way to access an external API from within Drupal? I need to show things like search results, listings, and listing summar

  • What is the best way to access a serial port from VBA? 2009-02-20

    What is the best way to access a serial port from VBA? I have a need for some of our sales reps to be able to send a simple string over the serial port from an action button in PowerPoint. I don't commonly use VBA, especially for anything like this.

  • The definitive best way to preload images using JavaScript/jQuery? 2009-05-23

    I'm fully aware that this question has been asked and answered everywhere, both on SO and off. However, every time there seems to be a different answer, e.g. this, this and that. I don't care whether it's using jQuery or not - what's important is tha

  • What's the best way to switch images on mouse-over events? 2011-01-14

    What's the best way to switch images on mouse-over events ? I want to swap 2 images when I move the mouse over and out an object on my webpage. I would like to know for both cases: - css-background images assigned to , , elements (image url is in css

  • What's the best way to store images in android? 2011-04-20

    This question already has an answer here: Efficient Way to store images in android 1 answer What is the best way to store images in android? Also is it possible to access jsp pages from a web service call in android and how to do it? Thanks, Sneha --

  • best way to download large files from azure cloud storage 2011-05-13

    I have an MVC web app running in azure that serves up large files like mp3's, pdf's, etc... that are stored in cloud storage. What's the best way to serve those files, so users can download them when clicking on a link/button? The easy way is just to

  • Best way to access sqlite database in read mode using php 2011-07-16

    Couple questions. Whats the best way to access a live .db file using sqlite to just read data? Secondly $url = "data.db"; try { $db = new PDO('sqlite:"$url"'); ... How can I correct this syntax so I can set the database url as a variable? If I must u

  • Best way of saving images in the server side 2011-12-05

    Possible Duplicate: Saving images: files or blobs? im building a site which will have large no of images. so i want to know the best way to save images in the database. Saving images in database in a BLOB field Saving images in databases as text Savi

  • Best way to store images in sql server on a network server 2011-12-16

    I'm developing an application that needs to store large images and about 100 image a day about 3 people work on the same application DB (desktop application connected to same db) any one of theme can view , edit, delete other work which means all of

  • Best way to access List in one class from another class 2012-01-18

    I have a class, lets call it 'Words', that reads a file and creates a list of strings. I then have a class, 'Items', that creates a list of 'description' objects, each description object needs access to the list from 'Words'. Since the 'Word' list re

  • What is the best way to access deque's element in C++ STL library 2012-01-22

    I have a deque: deque<char> My_Deque; My_Path.push_front('a'); My_Path.push_front('b'); My_Path.push_front('c'); My_Path.push_front('d'); My_Path.push_front('e'); There are such ways to output it. The first: deque<char>::iterator It; for

  • Best way of loading images from application bundle 2012-02-07

    What is the best way of loading images from the application main bundle. I am using [UIImage imageNamed: "image.png"]; But I have heard that this is not good in terms of memory usage and performance. Can anyone please give his/her feedback on it? My

  • Best way to store uploaded files in a Spring MVC environnment 2012-02-24

    The question is quite easy: what is the best way to store uploaded files in a clustered Spring MVC environnment? Example: let's say I'm coding a social network and I have to possibility to upload my personal profile picture. The user will then have a

  • What is the best way to convert pdf file into power point slides? 2014-09-13

    There are several situations where we need to convert a pdf file into power point presentation. For example most of the research papers on IEEE Xplore are in pdf. Then there are various documents available from corporate sites, phd/MS thesis/reports

  • What's the best way of accessing field in the enclosing class from the nested class? 2008-10-08

    Say if I have a dropdown in a form and I have another nested class inside of this class . Now what's the best way to access this dropdown from the nested class? --------------Solutions------------- Unlike Java, a nested class isn't a special "inner c

  • What the best way to access the database inside a class in PHP? 2008-10-30

    I have a session class that needs to store session information in a MySQL database. Obviously I will need to query the database in the methods of this class. In general I may need to connect more than one database simultaneously and may or may not be

  • Best way to access The MS-Exchange Global Access List from a .net application 2009-02-07

    Which is the best way to access the corporate MS-Exchange GAL (Global Access List - The list of the corporate ID/GroupIDS) from a .net application? We could use CDO, MAPI, LDAP etc but i am looking forward to a solution which is faster and is compati

  • What is the best way to access data in a normalized database schema? 2009-02-08

    I've got a problem that keeps coming up with normalized databases and was looking for the best solution. Suppose I've got an album information database. I want to setup the schema in a normalized fashion, so I setup two tables - albums, which has one

  • Best way to pass a file to a function 2009-03-06

    I'm working on a VB.NET DLL right now, and one of the functions I'm writing is supposed to take a file, and clip out an array of bytes (the method I've got works, and can be abstracted away here). What's the best way to pass a file to this function?

Copyright (C), All Rights Reserved.

processed in 0.169 (s). 11 q(s)