using Photoshop;
using System.IO;
namespace Image_Converter
{
public partial class Form1 : Form
{
Photoshop.Application appRef = default(Photoshop.Application);
Photoshop.Document currentDoc = default(Photoshop.Document);
public Form1()
{
InitializeComponent();
}
private void convert_Click(object sender, EventArgs e)
{
long originalWidth;
long originalHeight;
if (txtFrom.Text != "" && txtTo.Text!= "")
{
Thread th_1 = new Thread(new ThreadStart(show));
try
{
th_1.Start();
appRef = new Photoshop.Application();
appRef.Visible = false;
appRef.DisplayDialogs = PsDialogModes.psDisplayNoDialogs;
String[] files = Directory.GetFiles(txtFrom.Text);
foreach (string fl in files)
{
if (fl.EndsWith(".jpg") || fl.EndsWith(".jpeg"))
{
currentDoc = appRef.Open(fl);
currentDoc.ChangeMode(PsChangeMode.psConvertToCMYK);
appRef.Preferences.RulerUnits = Photoshop.PsUnits.psPixels;
originalHeight = (long)currentDoc.Height;
originalWidth = (long)currentDoc.Width;
int targetHeight = (int)(originalHeight);
int targetWidth = (int)(originalWidth);
Photoshop.JPEGSaveOptions jpeg = new Photoshop.JPEGSaveOptions();
jpeg.Quality = 8;
currentDoc.ResizeImage(targetWidth, targetHeight, 300, PsResampleMethod.psBicubic);
string temp = txtTo.Text + Path.GetFileName(fl);
currentDoc.SaveAs(txtTo.Text + "\\" + Path.GetFileName(fl), jpeg);
currentDoc.Close(PsSaveOptions.psDoNotSaveChanges);
}
}
}
catch (Exception ex) {
MessageBox.Show(ex.ToString());
label3.Hide();
}
using System.IO;
namespace Image_Converter
{
public partial class Form1 : Form
{
Photoshop.Application appRef = default(Photoshop.Application);
Photoshop.Document currentDoc = default(Photoshop.Document);
public Form1()
{
InitializeComponent();
}
private void convert_Click(object sender, EventArgs e)
{
long originalWidth;
long originalHeight;
if (txtFrom.Text != "" && txtTo.Text!= "")
{
Thread th_1 = new Thread(new ThreadStart(show));
try
{
th_1.Start();
appRef = new Photoshop.Application();
appRef.Visible = false;
appRef.DisplayDialogs = PsDialogModes.psDisplayNoDialogs;
String[] files = Directory.GetFiles(txtFrom.Text);
foreach (string fl in files)
{
if (fl.EndsWith(".jpg") || fl.EndsWith(".jpeg"))
{
currentDoc = appRef.Open(fl);
currentDoc.ChangeMode(PsChangeMode.psConvertToCMYK);
appRef.Preferences.RulerUnits = Photoshop.PsUnits.psPixels;
originalHeight = (long)currentDoc.Height;
originalWidth = (long)currentDoc.Width;
int targetHeight = (int)(originalHeight);
int targetWidth = (int)(originalWidth);
Photoshop.JPEGSaveOptions jpeg = new Photoshop.JPEGSaveOptions();
jpeg.Quality = 8;
currentDoc.ResizeImage(targetWidth, targetHeight, 300, PsResampleMethod.psBicubic);
string temp = txtTo.Text + Path.GetFileName(fl);
currentDoc.SaveAs(txtTo.Text + "\\" + Path.GetFileName(fl), jpeg);
currentDoc.Close(PsSaveOptions.psDoNotSaveChanges);
}
}
}
catch (Exception ex) {
MessageBox.Show(ex.ToString());
label3.Hide();
}