![]() No need for your device storage access, and also no need for login. If this could be altered, it would a lot better.WebThis tool will allow you to compress unlimited jpg images for free, and also provide a jpg converter service. ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Png) Bitmap bmp1 = new Bitmap(imageFile) //pathOfImage) UpdateStatusText = UpdateStatusText.Replace(ImageName, ImageName "," Status) įile.WriteAllText(_StatusLog, UpdateStatusText) įile.AppendAllText(_StatusLog, Environment.NewLine) įor PNG compression i changed the following line. String UpdateStatusText = File.ReadAllText(_StatusLog) Sec.AddAccessRule(new FileSystemAccessRule(everyone, FileSystemRights.Modify | FileSystemRights.Synchronize, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow)) ĭirectory.SetAccessControl(_StatusLog, sec) SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null) Public static void LoggingOperations(string ImageName, string Status, bool UpdateRequired)ĭirectorySecurity sec = Directory.GetAccessControl(_StatusLog) String RemovingImageFormat = splitingPathOfImage.ToString().Split('.') String splitingPathOfImage = pathOfImage.Split('\\') Public string GettingImageNameForOptimizedImage(string pathOfImage) ImageCodecInfo codecs = ImageCodecInfo.GetImageDecoders() ![]() Private ImageCodecInfo GetEncoder(ImageFormat format) System.IO.File.Move(filesInSubDir "\\" "Zip" GettingImageNameForOptimizedImage(imageFile), filesInSubDir "\\" GettingImageNameForOptimizedImage(imageFile)) Ĭonsole.Write("\n" ex.Message " Press enter to continue :") Ĭonsole.Write("\nWould you like to retry ? :") Ĭonsole.WriteLine(" -\n\n") Ĭonsole.Write("Press any key to exit.") #region BACK RENAMING FILE TO ORIGNAL NAME bmp1.Save("D:\\" RemovingImageFormat "100L" ".jpg", jpgEncoder, myEncoderParameters) myEncoderParameters.Param = myEncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 100L) System.IO.File.Delete(filesInSubDir "\\" GettingImageNameForOptimizedImage(imageFile)) //pathOfImageĬonsole.WriteLine(imageFile.Replace("jpg", "png") " DELETED") //pathOfImage MyEncoderParameters.Param = myEncoderParameter īmp1.Save(filesInSubDir "\\" "Zip" GettingImageNameForOptimizedImage(imageFile), jpgEncoder, myEncoderParameters) //pathOfImageĬonsole.WriteLine(filesInSubDir GettingImageNameForOptimizedImage(imageFile) " CREATED") //pathOfImage In this case, there is only oneĮncoderParameters myEncoderParameters = new EncoderParameters(1) ĮncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 50L) An EncoderParameters object has an array of EncoderParameter Create an Encoder object based on the GUID ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Jpeg) String allFilesInSubDir = Directory.GetFiles(filesInSubDir) įoreach (var imageFile in allFilesInSubDir)īitmap bmp1 = new Bitmap(imageFile) //pathOfImage) String subDirectory = Directory.GetDirectories(directory) // ATTRIBUTE DIRECTORY OPENįoreach (var filesInSubDir in subDirectory) String allDirectoryInTargetDirectory = Directory.GetDirectories(targetDirectory) Ĭonsole.Write("Total Folders found = " allDirectoryInTargetDirectory.Count()) įoreach (var directory in allDirectoryInTargetDirectory) String targetDirectory = pathOfImage //Console.ReadLine() Console.Write("Target Directory Path :") Private void VaryQualityLevel(string pathOfImage) public const string _StatusLog = "StatusLog.csv" Ĭonsole.Write("\n\nPlease enter image folder path :") Picture compressed about 90% and quality remain the same but when i compress a PNG image with it. I want to compress a PNG image, to reduce its size but the quality should remain the same.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |