sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [Plugin] ImageTrimmer

    Scheduled Pinned Locked Moved Plugins
    364 Posts 58 Posters 228.2k Views 58 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      rclubb
      last edited by

      I'm trying this plugin out on a pretty complex png. It appears to be running, going on about 3 hours now. Should I give up or do you think it's still going?

      Sketchup 2019.2
      late 2015 iMac (macOS Mojave 10.14.6)
      4GHz 4-core i7 processor
      32 GB 1867 DDR3 RAM
      AMD Radeon R9 M390 2 GB


      image is proprietary.

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Are the white pixels transparent ?
        Are the other colored pixels 100% solid ?
        Why no aggressively crop the PNG so that it's tight to what you want to keep - otherwise thousands of pixels get analyzed and throw away anyway !

        It shouldn't take more that 5mins...
        How big is that PNG ??

        TIG

        1 Reply Last reply Reply Quote 0
        • R Offline
          rclubb
          last edited by

          So, I tried to cut the transparent space down and now I get a error message:


          Screen Shot 2019-10-18 at 4.17.38 PM copy-Resized.png

          1 Reply Last reply Reply Quote 0
          • R Offline
            rclubb
            last edited by

            the white areas are all transparent. it is rectangle cropped as tight as possible.

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              I downloaded your original PNG and it trimmed just fine in a minute or two...
              However, the result is rubbish, because many of the colored pixels also have some transparency, also get trimmed !
              A simple PNG edit to flatten and reassign a transparent layer to just the white 'surround' gives a better result...
              However, given the relatively small size and resolution of the PNG the small areas - like the text - it still gives a pretty poor result...
              Capture.PNG

              From the screenshot you posted it looks like that's actually NOT an Image ?
              You have a selected face ??
              Did you adjust the PNG and get that result from ImageTrimmer ???
              I some ways it's better that mine ! As it keeps the text etc unaffected...

              Initially did you import it as an Image ? rather than a Texture...

              Also I can't see the advantage of trimming this PNG into a Component ??
              What's you end use plan ?
              Perhaps it'd be more useful as an imported Image overlaid onto your model ?

              TIG

              1 Reply Last reply Reply Quote 0
              • R Offline
                rclubb
                last edited by

                I imported the PNG in as and image. It's originally a vector I saved as a PNG.
                I traced out a rough line around the non-transparent areas to help speed up the Trimmer plugin but it didn't help. that's the screenshot I attached. When I traced it out and removed the empty space it made it no longer an image I think?
                I don't know how to save as a PNG from illustrator and not lose 100% solid colors. In my vector, all colors are solid.

                I want to place this on a 3d mock-up of a outdoor sign but it makes a black box around the PNG no matter what method I try.

                1 Reply Last reply Reply Quote 0
                • TIGT Offline
                  TIG Moderator
                  last edited by

                  You originally posted a PNG .
                  Why can't you just use that as an Image in your model ?
                  Just size/scale it to fix exactly onto the sign ??

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • Dave RD Offline
                    Dave R
                    last edited by

                    What if you just leave it as an image and float it off the sign slightly?
                    Screenshot - 10_21_2019 , 10_15_45 AM.png

                    Etaoin Shrdlu

                    %

                    (THERE'S NO PLACE LIKE)

                    G28 X0.0 Y0.0 Z0.0

                    M30

                    %

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      rclubb
                      last edited by

                      Thanks to both of you. for what ever reason, importing the image without trimming worked this time when before I had the black shadow behind. I guess I did something wrong last time.

                      Thanks

                      1 Reply Last reply Reply Quote 0
                      • Dave RD Offline
                        Dave R
                        last edited by

                        I suspect that before when you imported the image, your next step was to explode it. This would convert the image into a texture on a face the size of the image. I didn't explode the image in my example but if the image was exploded, you could hide the edges of the face so they aren't visible.

                        Etaoin Shrdlu

                        %

                        (THERE'S NO PLACE LIKE)

                        G28 X0.0 Y0.0 Z0.0

                        M30

                        %

                        1 Reply Last reply Reply Quote 0
                        • A Offline
                          avminkler
                          last edited by

                          Hi TIG,

                          This is a fantastic plugin, once I figure out how to work it! I've attached a sketch I did of a tree (which I know is a very complicated shape) but my hope is to get at least somewhat correct shadows for it. When I import it as an image and use the image trimmer, WinRAR immediately opens and asks me to extract 'Edgedetecor.jar'. Not sure if this is suppose to happen? I do see that a subfolder is created called 'Trimmedimages' and it has a high contrast version of my original in there. Nothing happens in the model itself though, the image isn't trimmed and no errors are given. I do get the 'Making Edges please wait' dialog at the bottom of Sketchup. I figured with my sketch maybe it was too complex so I tried a more simple PNG file of leaves that I've also attached. I'm using Windows 10 and Sketchup 2020. I know I'm doing something wrong, just don't know what. Any advise would be appreciated.

                          Thanks,
                          Vin


                          Oak Sketch 01.png


                          Branch (5).png

                          1 Reply Last reply Reply Quote 0
                          • TIGT Offline
                            TIG Moderator
                            last edited by

                            This issue is covered by the usage notes and in several posts in this thread...
                            ImageTrimmer uses JAR files - these are tiny applets to do image pixel manipulations etc, not available in older Ruby versions.
                            JAR files use Java.
                            It should be already installed on your PC - but if not then google it and install it.
                            It's known that some compression/unzipping apps - like WinRar - can 'hijack' the .JAR filetype and open that file.
                            The filetype .JAR must be associated with Java - not some other app - Java executes the JAR file rather than 'opens' it...
                            The issue is readily fixable.
                            Open your compression app's settings / options and there will be a section on the filetypes that the app will interact with [like .ZIP, .RAR etc], ensure that .JAR is NOT selected.

                            Try ImageTrimmer again...

                            While we are at it... please note how the PNG must contain opaque pixels for the solid areas and translucent pixels for the unwanted parts - typically the background.
                            I suggest you use something like Gimp to make a simple PNG with a clear pixel background and 100% solid other pixels, and test that, so you can see what's involved...

                            In Gimp you can process your PNG by flattening it - so there's no transparency for any of the pixels - then add an alpha-channel [layer] back...
                            Now if you use the magic-wand to select the color[s] of the unwanted background, and press delete the image should now show a transparent background.
                            That will be used to trim the image in ImageTrimmer...

                            Always tightly 'crop' the PNG as the unwanted parts get processed and take time - so if you've manually reduced the size it's best [your PNG image needs cropping]]

                            In passing your tree image does appear very complex and the monochrome pixels might make selecting/deleting the background less easy... Try the leaves PNG... it also needs substantial cropping, but has a transparent background but it's extent needs tidying up.
                            Thin twigs about a pixel wide will vanish... so I scaled up the image to avoid that, but it takes longer to process, so I also adjusted its contents to avoid the wait - it is overly complex for trimming...
                            I've done it for you - BUT please try it yourself...
                            It should take only a few seconds to process the reduced image - everything is exponential 2000 pixels takes 4x longer that 1000px.


                            Branch (5).png


                            ImageTrimmed.PNG

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • A Offline
                              avminkler
                              last edited by

                              Thank you TIG for taking the time to reply, even though you've done a similar reply in previous posts that I just didn't realize were to the same issue I was having.

                              Much appreciated!

                              1 Reply Last reply Reply Quote 0
                              • jenujacobJ Offline
                                jenujacob
                                last edited by

                                hi TIG,
                                I am on my work PC (Windows 10) and using SketchupPro 2020.
                                I have gone through the entire thread and tried to see what wrong but to no success.
                                i have made sure Java is installed and all permissions are at full.

                                in one of your post, you ask to paste the code and see what happens...
                                this is what turns up....
                                UI.openURL("file:///"+"../full/path/to/EdgeDetector.jar") false

                                while trying to run imagetrimmer on a file, this is what i see in the RC :

                                Error: #<Errno::ENOENT: No such file or directory @ rb_sysopen - C:\Users\jenu.varkey\Desktop\TrimmedImages\SS-Poem[Edges].dat> C:/Users/jenu.varkey/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/SKMtools/ImageTrimmer.rb:277:inreadlines'
                                C:/Users/jenu.varkey/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/SKMtools/ImageTrimmer.rb:277:in make_edges' C:/Users/jenu.varkey/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/SKMtools/ImageTrimmer.rb:201:in process_image'
                                C:/Users/jenu.varkey/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/SKMtools/ImageTrimmer.rb:170:in initialize' C:/Users/jenu.varkey/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/SKMtools/ImageTrimmer.rb:834:in new'
                                C:/Users/jenu.varkey/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/SKMtools/ImageTrimmer.rb:834:in block in <top (required)>'

                                any ideas?

                                1 Reply Last reply Reply Quote 0
                                • TIGT Offline
                                  TIG Moderator
                                  last edited by

                                  Could be several things...

                                  Are .jar files definitely set to open in Java - i.e. the file-type suffix hasn't been hijacked by a compression app ?

                                  Assuming that's OK can you post the PNG itself [so I can be sure what's wrong with it]... or try this fix...

                                  If all pixels have some transparency set [even a small amount] then it makes an empty file for 'edges' etc - there aren't any to find.

                                  The way to check this is to use say Gimp flatten the image - to remove all transparency - then add back a transparency [alpha] layer, then select the background pixels [using the magic-wand] and then delete those so you can see the checkerboard pattern...
                                  Crop the image to remove unwanted transparent area around its edges, which will be ignored anyway during the trimming, but which will have to be examined [fruitlessly]
                                  You should now have a usable solid image, with just the background pixels 100% transparent.
                                  Save the PNG and re-import / ImageTrimmer process again...

                                  Also note that any solid areas are unlikely survive if they are only 1 pixel wide, so consider this in the PNG...

                                  Good luck...

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • N Offline
                                    nixchambers1
                                    last edited by

                                    Dear TIG,
                                    Know you must be so sick of answering questions on this...

                                    So here's where I'm at:

                                    The Image must be imported as an Image, NOT a texture. - TICK ๐Ÿ‘
                                    It must be a PNG. - TICK ๐Ÿ‘
                                    It must have a transparency alpha-channel. - TICK ๐Ÿ‘
                                    The background pixels to be removed must on that. - TICK ๐Ÿ‘
                                    ALL other pixels must be 100% opaque. - TICK ๐Ÿ‘
                                    If they have any transparency at all they will also be removed ! - NOTED ๐Ÿ‘

                                    Save the PNG and import it as an Image into your SKP. - TICK ๐Ÿ‘

                                    Select it. - TICK ๐Ÿ‘
                                    Choose ImageTrimmer on the Tools menu. TICK ๐Ÿ‘
                                    Answer the prompts... NOPE - NO PROMPTS, HOWEVER, I GET THE THE LINE, DAT AND PNG FILE IN THE SUBFOLDER (SEE ATTACHMENTS) ๐Ÿ˜•

                                    Run with the Ruby Console open to see if there are any error-massages...

                                    HERE'S WHAT I GET: ๐Ÿ˜ฎ

                                    Error: #<NoMethodError: undefined method length' for nil:NilClass> C:/Users/nixch/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/SKMtools/ImageTrimmer.rb:278:in make_edges'
                                    C:/Users/nixch/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/SKMtools/ImageTrimmer.rb:201:in process_image' C:/Users/nixch/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/SKMtools/ImageTrimmer.rb:170:in initialize'
                                    C:/Users/nixch/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/SKMtools/ImageTrimmer.rb:834:in new' C:/Users/nixch/AppData/Roaming/SketchUp/SketchUp 2020/SketchUp/Plugins/SKMtools/ImageTrimmer.rb:834:in block in <top (required)>'

                                    Java installed and enabled on your computer [the usual default]. - TICK ๐Ÿ‘
                                    Also check that the .jar file-type is set to open with Java [execute] and NOT to open in your [de]compression application - some hijack various file extensions that are used by things like Java and stop them executing... - TICK ๐Ÿ‘
                                    [/attachment]Java file-type default

                                    โžก The only slightly untoward event is that my virus protector is giving me a sequence of 3 warnings (I've attached 2). I hit the "Allow" every time (even when I've told it not to prompt me for 30 minutes it still pops up).

                                    Windows 10, Sketchup Pro 2020
                                    Have attempted on 2 other png images and same sequence.

                                    Please help...

                                    [attachment=4:9vweqji1]<!-- ia4 -->shrub_Elev_2[Edges].png
                                    [attachment=3]shrub_Elev_2.png<!-- ia4 -->[/attachment:9vweqji1]


                                    Found in Subfolder


                                    Found in Subfolder


                                    Anti-Virus Pop-up


                                    Anti-Virus Pop-Up2

                                    1 Reply Last reply Reply Quote 0
                                    • TIGT Offline
                                      TIG Moderator
                                      last edited by

                                      What you have done so far seems fine.
                                      I repeated it with your PNG and got this result attached...
                                      My SKP was on my Desktop, but ones in my Documents folder work fine too...

                                      The main difference seems to be your over-zealous AntiVirus tool which attempts to block the JAR files running - not seen that before !
                                      Do you tick the box to remember the allowance ?
                                      You must allow it to create the files [obviously], when first run you might be causing a glitch by the interruption - but after that if you told it to ignore the JAR's actions it should be OK ??

                                      You could also try switching off the AntiVirus briefly while running the tool and see if that is indeed the culprit...
                                      What s your AntiVirus app ?

                                      Capture.PNG

                                      TIG

                                      1 Reply Last reply Reply Quote 0
                                      • N Offline
                                        nixchambers1
                                        last edited by

                                        So I temporarily switched off Anti-Virus Protector (Kaspersky) and it worked. Hooray! ๐ŸŽ‰

                                        Weirdly, no matter what I did (allow, remember my preferences etc etc) it kept re-prompting me.
                                        I've had plenty of issues with it being over-zealous. I guess that's preferential to being under-enthusiastic at protecting my computer, just a bit of a faff. ๐Ÿ˜†

                                        Only issue I have now is that when I change the axis in the lovely new component it moves the texture around but that's not a big worry. Can sort that out myself I reckon.

                                        Thanks a mill for your help. ๐Ÿ˜Ž

                                        @tig said:

                                        What you have done so far seems fine.
                                        I repeated it with your PNG and got this result attached...
                                        My SKP was on my Desktop, but ones in my Documents folder work fine too...

                                        The main difference seems to be your over-zealous AntiVirus tool which attempts to block the JAR files running - not seen that before !
                                        Do you tick the box to remember the allowance ?
                                        You must allow it to create the files [obviously], when first run you might be causing a glitch by the interruption - but after that if you told it to ignore the JAR's actions it should be OK ??

                                        You could also try switching off the AntiVirus briefly while running the tool and see if that is indeed the culprit...
                                        What s your AntiVirus app ?

                                        [attachment=0:dc4tca6g]<!-- ia0 -->Capture.PNG<!-- ia0 -->[/attachment:dc4tca6g]

                                        1 Reply Last reply Reply Quote 0
                                        • TIGT Offline
                                          TIG Moderator
                                          last edited by

                                          Why do you need to move the axes ?
                                          If the image has become a component, then select that and explode then remake the component this time setting its axes where you want - at that point the texture shouldn't 'jump' ??
                                          Use the same name to overwrite the original...

                                          TIG

                                          1 Reply Last reply Reply Quote 0
                                          • N Offline
                                            nixchambers1
                                            last edited by

                                            Will do, thanks.
                                            I move the axes upwards slightly for most shrubs so that they "sit" on the planting surface in a more credible way - essentially planting them slightly buried. ๐Ÿค“

                                            @tig said:

                                            Why do you need to move the axes ?
                                            If the image has become a component, then select that and explode then remake the component this time setting its axes where you want - at that point the texture shouldn't 'jump' ??
                                            Use the same name to overwrite the original...

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 14
                                            • 15
                                            • 16
                                            • 17
                                            • 18
                                            • 19
                                            • 16 / 19
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement