Jump to content
You must now use your email address to sign in [click for more info] ×

Unexpected Feature: Vectorize a Bitmap Image Directly in Publisher


Recommended Posts

Believe it or not, a rudimentary vectorizer has been included with Affinity from the very launch of Publisher 1!
Before you get too excited though: it only works on images with transparency, for example 1-bit images with alpha channel.
But hey, better than nothing, right?

  1. Place your image into a Publisher document, the more pixels the original image has, the better
  2. Select the image and click the Edit Wrap Outline button in the main toolbar
  3. Copy
  4. Paste = Curves object: there's your image (roughly) vectorized, traced based on the transparency outline
  5. Apply fill and stroke as you see fit
  6. Optionally convert all the sharp nodes to smooth or smart nodes to make it appear less jagged, clean up as you see fit

Tested in APu v1.10.6 Mac and APu v2.0.3 iPad.

apu_trace_image_wrap_outline.png.6a54afe7e29811b32acdb86f7e148f4a.png

MacBookAir 15": MacOS Ventura > Affinity v1, v2, v2 beta // MacBookPro 15" mid-2012: MacOS El Capitan > Affinity v1 / MacOS Catalina > Affinity v1, v2, v2 beta // iPad 8th: iPadOS 16 > Affinity v2

Link to comment
Share on other sites

Works perfectly for vectorizing bitmap QR codes:

apu_trace_image_wrap_outline_qr_code.png.b2292a93c79e661756ac48157a78b17d.png

If the image doesn't have transparency yet, all you need to do is:

  1. Place the QR code image in Publisher and select it with the Move tool
  2. Context toolbar > Edit Image
  3. Switch the opened image to the Photo persona
  4. Flood Select tool > Contiguous: off > click the white background
  5. Delete (optionally enable Transparent Background to check if all white pixels are gone)
  6. Save (if PNG) or export as PNG (if JPEG, then replace the JPEG in the other afpub)
  7. proceed with Wrap Outline as above

MacBookAir 15": MacOS Ventura > Affinity v1, v2, v2 beta // MacBookPro 15" mid-2012: MacOS El Capitan > Affinity v1 / MacOS Catalina > Affinity v1, v2, v2 beta // iPad 8th: iPadOS 16 > Affinity v2

Link to comment
Share on other sites

Really nice catch. 👌👍👍👍

Mac mini M1 A2348

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

 

Link to comment
Share on other sites

Remember, you can convert any color to transparent with help of blend ranges.

More complex color transformations are possible with Chanel mixer or Procedural Texture filter.

Use posterize or gradient map for multi-pass tracing specific color ranges.

The new hue/luminosity live filter mask come handy.

Mac mini M1 A2348

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

 

Link to comment
Share on other sites

Does it generate 2-4 nodes per pixel - at every pixel edge in principle? (No opportunity to try it on my own today)

Mac mini M1 A2348

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

 

Link to comment
Share on other sites

8 hours ago, NotMyFault said:

Remember, you can convert any color to transparent with help of […]

Yep, it opens quite a few possibilities, for instance by using some clever APh macros.

8 hours ago, NotMyFault said:

Does it generate 2-4 nodes per pixel - at every pixel edge in principle?

Something like that, as it seems.
^ Actually strike that, it's vice versa: more like a node per 8 pixels or so. Hence the jagged edges. Because generally that's "good enough" for text wrap, isn't it.

But before posting, I did a few tests to figure out what can make a difference. In the end it boils down to the sheer amount of pixels. More is more.
But… the more pixels, the more nodes. The more nodes, the more… troubles. There were a bunch of crashes and spin dumps along the way.

Edited by loukash
see strikethrough

MacBookAir 15": MacOS Ventura > Affinity v1, v2, v2 beta // MacBookPro 15" mid-2012: MacOS El Capitan > Affinity v1 / MacOS Catalina > Affinity v1, v2, v2 beta // iPad 8th: iPadOS 16 > Affinity v2

Link to comment
Share on other sites

2 hours ago, loukash said:

Believe it or not, a rudimentary vectorizer has been included with Affinity from the very launch of Publisher 1!
Before you get too excited though: it only works on images with transparency, for example 1-bit images with alpha channel.

apu_trace_image_wrap_outline.png.6a54afe7e29811b32acdb86f7e148f4a.png

giphy.gif

Microsoft Windows 10 Home (Build 19045)
AMD Ryzen 7 5800X @ 3.8Ghz (-30 all core +200mhz PBO); Mobo: Asus X470 Prime Pro
32GB DDR4 (3600Mhz); EVGA NVIDIA GeForce GTX 3080 X3C Ultra 12GB
Monitor 1 4K @ 125% due to a bug
Monitor 2 4K @ 150%
Monitor 3 (as needed) 1080p @ 100%

WACOM Intuos4 Large; X-rite i1Display Pro; NIKON D5600 DSLR

Link to comment
Share on other sites

43 minutes ago, NotMyFault said:

color to transparent with help of blend ranges

That doesn't work non-destructively in place. The image/pixel layer must be flattened with "real" transparency.
Also, the "absolute pixel grid" bug is an issue. Hence my workflow via Edit Image in a separate document, i.e. without any potential misalignment in the existing layout.

MacBookAir 15": MacOS Ventura > Affinity v1, v2, v2 beta // MacBookPro 15" mid-2012: MacOS El Capitan > Affinity v1 / MacOS Catalina > Affinity v1, v2, v2 beta // iPad 8th: iPadOS 16 > Affinity v2

Link to comment
Share on other sites

It has a million points to it, but it works-ish.

image.thumb.png.ccf957d11a0d9632bb903efc9db41314.png
 

image.thumb.png.cc06b1084cf4938fa3385484944d986c.png

Paste into Designer (as curves). mmm 8-bit.

image.thumb.png.1002a4260add941b017be389dc76e817.png

Microsoft Windows 10 Home (Build 19045)
AMD Ryzen 7 5800X @ 3.8Ghz (-30 all core +200mhz PBO); Mobo: Asus X470 Prime Pro
32GB DDR4 (3600Mhz); EVGA NVIDIA GeForce GTX 3080 X3C Ultra 12GB
Monitor 1 4K @ 125% due to a bug
Monitor 2 4K @ 150%
Monitor 3 (as needed) 1080p @ 100%

WACOM Intuos4 Large; X-rite i1Display Pro; NIKON D5600 DSLR

Link to comment
Share on other sites

11 minutes ago, debraspicher said:

It has a million points to it

Straight lines are relatively easy to clean up, simply select all nodes inbetween two corners with the node-lasso and delete them.
To clean up round curves, it would need a quick method to select e.g. every 2nd node, delete the "steps", then convert the rest to smooth.

MacBookAir 15": MacOS Ventura > Affinity v1, v2, v2 beta // MacBookPro 15" mid-2012: MacOS El Capitan > Affinity v1 / MacOS Catalina > Affinity v1, v2, v2 beta // iPad 8th: iPadOS 16 > Affinity v2

Link to comment
Share on other sites

Here an example how to quickly vectorize a part of a photo – i.e. a pixel selection – in place:

Yeah, it's gonna be jagged. Get over it. That's jazz. :P 

MacBookAir 15": MacOS Ventura > Affinity v1, v2, v2 beta // MacBookPro 15" mid-2012: MacOS El Capitan > Affinity v1 / MacOS Catalina > Affinity v1, v2, v2 beta // iPad 8th: iPadOS 16 > Affinity v2

Link to comment
Share on other sites

To smooth the jagged edges, go to Designer persona and apply multiple steps of the following until you're satisfied with the result:

  1. select all nodes > apply Corner Tool > Rounded > ~20 px (or about 2 mm @ 300 dpi) > Bake Appearance
  2. select all nodes > click the Smooth Curve button a few times
  3. select all nodes > click Convert: Sharp button
  4. repeat steps 1 > 2 > 3 > etc. > 1 > 2
  5. optionally apply Contour Tool or similar to your liking

Works surprisingly well within a minute or so.

Black is the initial jagged "million-nodes" vectorization of the hidden pixel layer, red overlay is a smoothed copy using several passes of the above workflow:

apu_trace_image_wrap_outline_smooth.png.739c32f8e7e1568294546467cf1390d6.png

Not all that shabby, huh? :) 

MacBookAir 15": MacOS Ventura > Affinity v1, v2, v2 beta // MacBookPro 15" mid-2012: MacOS El Capitan > Affinity v1 / MacOS Catalina > Affinity v1, v2, v2 beta // iPad 8th: iPadOS 16 > Affinity v2

Link to comment
Share on other sites

Aaand vice versa, using the Edit Wrap Outline you can create fake pseudo-bitmap vector shapes of smooth curves! :D 

MacBookAir 15": MacOS Ventura > Affinity v1, v2, v2 beta // MacBookPro 15" mid-2012: MacOS El Capitan > Affinity v1 / MacOS Catalina > Affinity v1, v2, v2 beta // iPad 8th: iPadOS 16 > Affinity v2

Link to comment
Share on other sites

Tracing some "vector" brushes:

apu_trace_vector_brush_wrap_outline.png.cd990fb8caca6a09b374883ee8f16c20.png

The trick: rasterize them first but avoid too many semi-transparent pixels. Fake "1-bit" images without antialiasing work best for tracing.

And again: the bigger the better.
Make sure your canvas is thousands of pixels wide for tracing. Heck, try ten thousands! (Save early, save often! :D)

MacBookAir 15": MacOS Ventura > Affinity v1, v2, v2 beta // MacBookPro 15" mid-2012: MacOS El Capitan > Affinity v1 / MacOS Catalina > Affinity v1, v2, v2 beta // iPad 8th: iPadOS 16 > Affinity v2

Link to comment
Share on other sites

7 hours ago, loukash said:

To smooth the jagged edges, go to Designer persona and apply multiple steps of the following until you're satisfied with the result:

  1. select all nodes > apply Corner Tool > Rounded > ~20 px (or about 2 mm @ 300 dpi) > Bake Appearance
  2. select all nodes > click the Smooth Curve button a few times
  3. select all nodes > click Convert: Sharp button
  4. repeat steps 1 > 2 > 3 > etc. > 1 > 2
  5. optionally apply Contour Tool or similar to your liking

Works surprisingly well within a minute or so.

Black is the initial jagged "million-nodes" vectorization of the hidden pixel layer, red overlay is a smoothed copy using several passes of the above workflow:

apu_trace_image_wrap_outline_smooth.png.739c32f8e7e1568294546467cf1390d6.png

Not all that shabby, huh? :) 

NO…Not at all…. I think I could totally live with that in 90% of my applications of the technique….

Link to comment
Share on other sites

  • 5 months later...

Brilliant! The perfectionist in me will want to go in a tweak all the little crevices, but this technique is a great starting point.

I think it also proves the capability for auto-trace already exists in Affinity, just needs some polish to bring it up to the "full tool/feature" level.

Link to comment
Share on other sites

I think this thread perfectly illustrates how one person's bug is another person's feature. Personally, I cringe every time I have to use the text wrap alpha feature in Publisher as I always end up having to go and delete 99% of the nodes and then redraw the shape (incl. curves) with a more reasonable node count which then allows me to tweak the shape to get the wrapping to work better. I'm always amazed at @loukash's ability to find endless (and ingenious) workarounds in the Affinity suite.

Hopefully we see improvements to both auto-trace tool and node/geometry clean-up tools in the not-too-distant future. 🤞

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.