c# - Create and save a thumbnail from an image which is loaded from a file -


how can create , save thumbnail image loaded file in vba?

  1. load image memory based on string defines path file
  2. make thumbnail of image
  3. save image folder jpg

i know how write in c#. tried make external exe file purpose somehow not work when try run via vba shell works if pass argument via windows explorer.

this full c# code of thumbmaker:

using system; using system.drawing;  class program {     static void main(string[] args)     {         if (args.length == 2)         {             string inputpath = args[0];             string outputpath = args[1];             try             {                 bitmap b = (bitmap)bitmap.fromfile(@inputpath);                 b.getthumbnailimage(160, 160, null, intptr.zero).save(outputpath);                 console.writeline(inputpath);                 console.writeline(outputpath);                 console.writeline(b.height);                 console.readline();              }             catch             {                 console.writeline("something went wrong, input file not converted bitmap");                 console.readline();             }         }         else         {             console.writeline("you must run program 2 parameters");             console.writeline("1. inputpath , 2. outputpath");             console.readline();         }     } } 

this needed translate vba:

bitmap b = (bitmap)bitmap.fromfile(@inputpath); b.getthumbnailimage(160, 160, null, intptr.zero).save(outputpath); 

this vba attempt not working:

private sub uploadbutton_click()      dim strprogramname string     dim strargument1 string     dim strargument2 string      strprogramname = initialization.imagespath & "thumbnailmaker.exe"     strargument1 = pathtextbox.text     'strargument2 = imageid & "_img" & imagenumber & ".jpg"     strargument2 = "newimg.jpg"      call shell("""" & strprogramname & """ """ & strargument1 & """ """ & strargument2 & """", 1)   end sub 

well assuming trying create thumbnail using external program, go this:

process.start("c:/path/thumbnailmaker.exe", "your arguments external  program here i.e. filepath: initialization.imagespath") 

then if can specify output name of file 3rd party program, can use argument , grab file since got name. otherwise, if program uses randomizes output filenames reason, work systemfilewatch , filename.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -