Jump to content

otuncelli

Members
  • Posts

    48
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by otuncelli

  1. I'm happy it worked for your case 😊 Yes, it can resize using many many different techniques. There is interpolative resizing with different modes, scaling and adaptive-resizing options. I don't know which will work best with image tracing. The example code below using "box" filter. Also converts the resulting image to 300ppi. I've also updated the link. @echo off SET /p TOLERANCE="Tolerance (Default: 20): " || SET "TOLERANCE=20" SET /p MAGICKDIR="ImageMagick Directory (Default: C:\Program Files\ImageMagick-7.1.0-Q16-HDRI): " || SET "MAGICKDIR=C:\Program Files\ImageMagick-7.1.0-Q16-HDRI" SET /p POINT="Pick Color Point (Default: 0,0): " || SET "POINT=0,0" SET /p INPUT_DIR="Input Directory: " SET /p OUTPUT_DIR="Output Directory: " @echo on FOR %%a IN (%INPUT_DIR%\*.png) DO "%MAGICKDIR%\magick.exe" convert "%%~a" ^ -background white ^ -gravity center ^ -extent 105%%x105%% ^ -fuzz %TOLERANCE%%% ^ -fill transparent ^ -draw "color %POINT% floodfill" ^ -trim ^ -units PixelsPerInch ^ -density 300 ^ -filter box ^ -resize 3000x3000 ^ -background transparent ^ -gravity center ^ -extent 3000x3000 ^ "%OUTPUT_DIR%\%%~nxa" @echo "Done!" @echo off PAUSE Thanks to ImageMagick developers. Photoshop's batch processing is so limited compared to it, and it's there mainly for marketing. I'm glad this forum is not as strict as Photoshop's. So we can talk about other tools and suggest alternative ways to achive something.
  2. Yes, I fixed it. You can use the same link to get it. It'll now first extend the canvas size by 5 percent.
  3. I've to admit this is a bit technical since there is not much user interface. I'll try to explain as simple as I can. After installing ImageMagick, you don't need to run anything in it. This program doesn't work that way. It has no user interface at all. Just note the location where its installed on your computer. In my case it was in C:\Program Files\ImageMagick-7.1.0-Q16-HDRI. Then download this file anywhere on your computer and run it (Basically, this is the .bat file that contains the same code above): https://drive.google.com/file/d/1xKbX9CiTdBeUz53nECjyruruNSSiy8nM/view?usp=sharing It'll ask you to enter 5 parameters. For the first 3 parameters I'm using the defaults. So I skipped those just by pressing enter key. If you installed ImageMagick into another directory than mine, you'll need to enter its path here. Then I enter input and output directories. After that, It should start to generate images in output directory. Their backgrounds are removed and cropped.
  4. -trim command should do the trick. Here is the updated code. @echo off SET /p TOLERANCE="Tolerance (Default: 20): " || SET "TOLERANCE=20" SET /p MAGICKDIR="ImageMagick Directory (Default: C:\Program Files\ImageMagick-7.1.0-Q16-HDRI): " || SET "MAGICKDIR=C:\Program Files\ImageMagick-7.1.0-Q16-HDRI" SET /p POINT="Pick Color Point (Default: 0,0): " || SET "POINT=0,0" SET /p INPUT_DIR="Input Directory: " SET /p OUTPUT_DIR="Output Directory: " @echo on FOR %%a IN (%INPUT_DIR%\*.png) DO "%MAGICKDIR%\magick.exe" convert "%%~a" -fuzz %TOLERANCE%%% -fill transparent -draw "color %POINT% floodfill" -trim "%OUTPUT_DIR%\%%~nxa" @echo "Done!" PAUSE
  5. Hi @MarijaM, AFAIK, You can't do batch processing in Paint.NET. You can do it with ImageMagick though. Steps: Download & Install ImageMagick (My installation location is in C:\Program Files\ImageMagick-7.1.0-Q16-HDRI) Make sure you've a backup copy of original images. Save the code below into a .bat file and run it. It'll ask you to enter some parameters. @echo off SET /p TOLERANCE="Tolerance (Default: 20): " || SET "TOLERANCE=20" SET /p MAGICKDIR="ImageMagick Directory (Default: C:\Program Files\ImageMagick-7.1.0-Q16-HDRI): " || SET "MAGICKDIR=C:\Program Files\ImageMagick-7.1.0-Q16-HDRI" SET /p POINT="Pick Color Point (Default: 0,0): " || SET "POINT=0,0" SET /p INPUT_DIR="Input Directory: " SET /p OUTPUT_DIR="Output Directory: " @echo on FOR %%a IN (%INPUT_DIR%\*.png) DO "%MAGICKDIR%\magick.exe" convert "%%~a" -fuzz %TOLERANCE%%% -fill transparent -draw "color %POINT% floodfill" "%OUTPUT_DIR%\%%~nxa" @echo "Done!" PAUSE Parameters Tolerance: Similar to magic wand tool's tolerance level. ImageMagick Directory: ImageMagick installation directory Point: Similar to magic wand tool's initialization point. ( Default value of 0,0 means top-left corner of the image ) Input Directory: Png files with backgrounds. Output Directory: Png files without backgrounds will be saved into this directory.
  6. I've discovered closing and re-opening Settings->Tools panel multiple times linearly increases the GDI object count in my tests. It's visible here because this panel contains a lot of icons.
  7. Hi @JMC, Apps from Windows Store install in a special folder that is hidden from users. You can install the plugins to this folder: <Documents>\paint.net App Files More detail here: https://www.getpaint.net/doc/latest/InstallPlugins.html
  8. ImPDF.Save doesn't require GhostScript, and provides more options for preparing printer-ready PDFs (page sizes, orientation, margins etc..). You can disable Save functionality on my alternative plugin and use ImPDF.Save for saving if you'd prefer. (I described how to do this in the topic.) Alternative plugin doesn't "require" to remove any other plugin, it's just my recommendation to prevent "highly possible" conflicts. I don't know how Paint.NET handles these situations thus it's just I can't officially say to users that they can use both at the same time without any problem.
  9. You can also try wrapping the Dictionary to Lazy<T> if it needs to be initialized at startup and only once. This'll both solve the problem and improve the startup performance.
  10. Hi @sansuamorera, Did you try Layers->Rotate/Zoom? (CTRL+Shift+Z) It has a Tiling option. You may need to work on a large canvas for creating the main image to get a high quality result. Then, zoom-out while Tiling option is checked. Still not realtime though.
  11. I checked paintdotnet.deps.json file. C++/CLI libraries have references (e.g. PaintDotNet.SystemLayer.Native.x86/x64/arm64.dll) but C libraries don't. I doubt that Visual Studio is that clever to generate .deps.json for p/invoked C libraries. I'm going to reference one of the bundled plugins here. WebP plugin has native libraries but I can't find any reference for WebP_x64/x86/ARM64.dll file in paintdotnet.deps.json file and it doesn't have WebPFileType.deps.json as well. Should they be manually added?
  12. .deps.json is meaningless for unmanaged dll dependencies. But tbh, subfolder is great feature for both plugin managability and code isolation. I'm encouraging my plugin' users to install in its own subfolder even it has no shared dlls.
  13. Oh yes, I see. That fixed it. Thanks.
  14. True, if it was a byte pointer. But its ColorBgra pointer. When I change width with stride it throws AccessViolationException. Also this gives the same result: ColorBgra* row = (ColorBgra*)((byte*)buf + y * stride);
  15. I was working with pixels and I've encountered a problem. Is there a bug in ColorBgra.Blend or am I doing something wrong? Here's a simple program to reproduce: class Program { static void Main() { // Generate original images for testing purposes Bitmap bmp1 = GetLoremIpsumWithAlphaBackground(); Bitmap bmp2 = new Bitmap(bmp1); Rectangle rect = new Rectangle(0, 0, bmp1.Width, bmp1.Height); // Test 1 BitmapData data1 = bmp1.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); BlendOverWhite(data1.Scan0, data1.Width, data1.Height, data1.Stride); bmp1.UnlockBits(data1); bmp1.Save("im1out.png"); // Test 2 BitmapData data2 = bmp2.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); BlendOverWhite2(data2.Scan0, data2.Width, data2.Height, data2.Stride); bmp2.UnlockBits(data2); bmp2.Save("im2out.png"); } private static unsafe void BlendOverWhite(IntPtr scan0, int width, int height, int stride) { ColorBgra white = ColorBgra.White; ColorBgra * buf = (ColorBgra * ) scan0; for (var y = 0; y < height; y++) { ColorBgra * row = buf + y * width; for (var x = 0; x < width; x++) { ColorBgra * pixel = row + x; ColorBgra blended = ColorBgra.Blend(white, * pixel, pixel - > A); * pixel = blended; } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static byte CustomBlend(int lhc, int rhc, int alpha, int alphaDiff) { return (byte)((rhc * alpha + lhc * alphaDiff) >> 8); } private static unsafe void BlendOverWhite2(IntPtr scan0, int width, int height, int stride) { ColorBgra white = ColorBgra.White; ColorBgra * buf = (ColorBgra * ) scan0; for (int y = 0; y < height; y++) { ColorBgra * row = buf + y * width; for (int x = 0; x < width; x++) { ColorBgra * pixel = row + x; int alpha = pixel - > A; int alphaDiff = byte.MaxValue - alpha; pixel - > B = CustomBlend(white.B, pixel - > B, alpha, alphaDiff); pixel - > G = CustomBlend(white.G, pixel - > G, alpha, alphaDiff); pixel - > R = CustomBlend(white.R, pixel - > R, alpha, alphaDiff); pixel - > A = white.A; // 255 } } } private static Bitmap GetLoremIpsumWithAlphaBackground() { const string text = @ "" "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. "" "; using(var font = new Font("Verdana", 12, FontStyle.Regular)) { SizeF sizef; using(var g = Graphics.FromHwnd(IntPtr.Zero)) { sizef = g.MeasureString(text, font); } Size size = Size.Round(sizef); var bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb); using(var g = Graphics.FromImage(bitmap)) { g.TextRenderingHint = TextRenderingHint.AntiAlias; g.DrawString(text, font, Brushes.Black, PointF.Empty); } bitmap.Save("im.png"); return bitmap; } } } Outputs: Original image (im.png) (text over transparent background): BlendOverWhite (im1out.png) (ColorBgra.Blend): BlendOverWhite2 (im2out.png) (CustomBlend):
  16. That was the idea of this topic Thank you for testing @Djisves.
  17. You need to use ValueTuple. Image_Rect.Add(new ValueTuple<int, int, int, int, int>(100, 0, 100, 0, 5)); Or using a syntactic sugar you can simply write like this: Image_Rect.Add((100, 0, 100, 0, 5));
  18. I might have an idea. I checked with ILSpy. PaintDotNet.Document.DpuUnit's getter and setter method seems to end up calling each other recursively. Floating point value equality check seems wrong in DpuX/DpuY setter methods which is called by DpuUnit's setter method. DpuUnit also sets DpuX and DpuY values to 1.0 in its setter. if (DpuUnit == MeasurementUnit.Pixel && value != 1.0) I'd do floating point equality checks with a tolerance value. Also ordering of expressions look important to me. Because second expression is depending on another property's value and this makes the code more prone to bugs. if (Math.Abs(value - 1.0) > 0.1 && DpuUnit == MeasurementUnit.Pixel)
  19. Same issue on UriProperty of PropertyBasedFileType plugins (i.e. DDSFileTypePlus). Clickable area is shorter than text.
  20. It was previously passing all tests on VeraPDF conformance test. But I checked again, It seems to fail on one now. Do you know any other conformance tests? Edit: Fixed the issue. Embedding layer/document properties won't break anything anymore. It passes conformance tests and Adobe Reader can open it.
  21. @lynxster4 Thanks for testing. Tbh, I've never tried opening with Adobe Reader. I'll look into it. I'm getting the same error. Edit: Turns out Adobe Reader doesn't like the way I embed PDN's layer & document configuration into the PDF. Foxit Reader and Mozilla don't have a problem with it though. I'll add an option to disable this. Edit 2: The option is added. Disabled by default. Edit 3: Fixed the main issue. Embedding layer and document configuration shouldn't cause any trouble now. The option is set to enabled again by default.
  22. I'd like to get feedback from experienced users before I release this file type plugin. Some features: PDF Open/Save. Adobe® Illustrator® Artwork (.ai) Open Only (Experimental). GhostScript is not required. Support for importing password protected PDFs. Saving protected PDFs is not supported yet. Native ARM64 support. But I couldn't test this because I don't have a compatible device. Can embed PDN's layer and document properties into PDF as marked object data. When you import that PDF again, they will be restored. But this is an alpha release and things might change. Supports exporting in PDF/A-1b, PDF/A-2b and PDF/A-3b standards. Supports embedding images in lossy (as JPEG) or lossless format. Has 4 modes for exporting: Normal: Each layer as page. Cropped: Bounding transparent pixels in each layer will be detected and removed automatically. So, in resulting PDF, each page can be different size. Cumulative: Each layer blends over the previous one using the selected blend option for that layer. Page 1 = Layer 0 Page 2 = Layer 0 + 1 ... Page n = Layer 0 + 1 + ... + n- The idea is from this topic: Flattened: Single page, flattened image. Has option to skip invisible or duplicate (containing same pixel data) layers when exporting. Allows importing all pages, certain pages, or same pages over and over again as different layers. Known Issues: Can't process very large images. (width x height x 4 > 2.147.483.647) Preview generation is not supported. Installation: Download and extract PdfFileTypePlugin.zip If you're using Paint.NET 4.3 or later: If you're using Classic version of Paint.NET: Create a new folder named PdfFileTypePlugin in the <Paint.NET>\FileTypes directory (default location is C:\Program Files\paint.net\FileTypes). If you're using Microsoft Store version of Paint.NET: Create a new folder named PdfFileTypePlugin in the <Documents>\paint.net App Files\FileTypes directory. Put the extracted files in this newly created folder. If you're using Paint.NET 4.2: If you're using Classic version of Paint.NET: Put the extracted files in the <Paint.NET>\FileTypes directory (default location is C:\Program Files\paint.net\FileTypes). If you're using Microsoft Store version of Paint.NET: Put the extracted files in the <Documents>\paint.net App Files\FileTypes directory. Optional: If you want to disable Save PDF functionality, create an empty text file named PdfFileType.DisableSave.txt in the same directory. If you want to disable Adobe® Illustrator® Artwork (.ai) support, create an empty text file named PdfFileType.DisableAi.txt in the same directory. Restart Paint.NET. Download Link
  23. Select the transparent pixels with Magic Wand tool. Apply Edit->Invert Selection (CTRL+I) Apply Image->Crop to Selection (CTRL+Shift+X)
×
×
  • Create New...