![]() ![]() Of course, not the Save as web, just one more step, we can reduce PNG file size but still maintain its image quality. That's it, we're using Adobe Photoshop to do it. All the time, the PNG optimizer is here with me. One of my friend showed us this technique to reduce PNG file size and I was pretty amazed. Though most of us has fast Internet, but it's good to optimized all the images to be as small as possible without losing quality. ![]() However, we're facing a problem, the file size of the PNG files are pretty massive. Usually, I would use JPEG or GIF, but this time, most of the images has drop shadow and the background of the website is tiled with clouds. I like png, it supports by all the browsers (except IE6, but you have the hack anyway). I hope I can show it here, but it haven't released yet. It's quite a sophisticated website when it also come with a jQuery scrolling effect. Due to the design, it needs heaps of png files so that I can use CSS to layer them together. If this could be altered, it would a lot better.Just recently, I was assigned to in charge of an iPhone game website. 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. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |