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

cutting 1 image into 4 equal parts


Recommended Posts

Hi everyone...... as per title, i simply want to cut a 12" x 12" image into 4 x 6" squares. iv googled and searched youtube but cant find an answer. one video i did watch showed how to slice via the Node Tool....is that the only way or is there a simpler way?. if i were to do it in silhouette studio could i just simply import it?

tony😉

Link to comment
Share on other sites

So something like this here, one of my own Java tools does something like that, it splits bitmap/raster images into predefined image segments ...

image-split.jpg.8ce6599222fc99e938d37ba18f19e6ba.jpg

... but with Affinity Photo, bitmap or vector?

Yes probably only via the "Export Persona" and then there manually setting up the needed 4x6 slices with the Slice-Tool. Afterwards exporting. - Or via some specific macro, but honestly it's not worth hazzling around and building one if other third party tools do already offer such things!

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

I would open the image and duplicate it and rasterize that duplicate. I would use the Guides manager to make two guides, at 50% vertical and horizontal. Lock the guides so as to not move them.

Now I would use the Rectangle tool to draw out a rectangle from one of the pixel layer's corners to the centre. Turn on the snapping for Margins and guides to assist.

Use the Select > Selection from Layer and Delete on that rectangle, copy the Pixel layer (the one made from the original image) and paste it. You will have a quadrant on a new pixel layer.

Select the Marquee tool and use that to move the selection to one of the other quadrants. Select the Pixel layer  (the one made from the original image) and copy and paste. 

Repeat the the process of move the selection and then select the Pixel layer  (the one made from the original image) and copy and paste until you are done.

Mac Pro (Late 2013) Mac OS 12.7.4 
Affinity Designer 2.4.1 | Affinity Photo 2.4.1 | Affinity Publisher 2.4.1 | Beta versions as they appear.

I have never mastered color management, period, so I cannot help with that.

Link to comment
Share on other sites

1 hour ago, Old Bruce said:

I would ...

LOL, I wouldn't, since I just load an image, adjust splitting-settings to my needs (4x6 etc.) and click on "Start splitting", after  <second I have all the image portions.

sample-run.jpg.301ef6ac6ed8459ba412e1991c451db1.jpg

 

4xbreite.jpg.f53c81f9713370656dff57f46b99191d.jpg

4xbreite2.jpg.31ffcd2d84296d643b866d2dfe99d385.jpg

And of course one sometimes might need the oposite tool too, aka one which can merge previously splitted images again together ...

image-merge.jpg.20031677b018527b3de37971ad97a2af.jpg

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

There are probably plenty of free online tools that can do this, e.g. https://pinetools.com/split-image, but if you do not want to use such services, and want to have more control, you could do this e.g. by creating multiple rectangles and align them to a grid, and then just clip copies of your images into these rectangles, e.g. in Photo, doing something like this:

 

You might want to trim and crop the rectangles to minimize the file size. If you have Designer, you could also use Export Persona and batch export the split layers easily in one go.

Link to comment
Share on other sites

On 11/15/2021 at 9:37 AM, Wosven said:

Or you can simply use the Fill tool with bitmap

Thanks, brilliant. I tried this first, too, but assumed that the rectangles need to be (initially) merged to be able to do this!

Combined with e.g. Corner Tool of Designer, and Export Persona, or with the copy paste help from VectorStyler using e.g. warps, it would be easy to create all kinds of manipulated tiled textures, as the split images would be handled as vector shapes:

 

 

 

Link to comment
Share on other sites

18 minutes ago, Hens said:

to stretch a bitmap fill on a group will be in one go

I am not sure what you mean: the bitmap will be applied in one go to any selection of shapes, whether grouped or not (but would not, if the shapes were merged, which I first tried, and as this did not work ended up placing copies of images manually into rectangles, which would be totally unnecessary by virtue of the bitmap fill, which, as @Wosven showed, can be applied in one action to all shapes involved).

Link to comment
Share on other sites

On 11/15/2021 at 2:20 PM, Hens said:

but you'll need to manually adjust to make it fit
If grouped you simply wiggle the centre node and the bitmap fill will adjust in one go

Ok, I see. perhaps it is related somehow to image size, or perhaps the OS version, as when I try this with the images large enough to fill the grid without stretching, I get identical behavior either way (grouped or non-grouped). On the other hand, as I just tested this on Windows, I get the following results:

 

That is, when grouped, the rectangles get filled as per "tile" size (until "nudged" to full grid width/height), when non-grouped, the image is scaled directly to the grid width (height). Perhaps there is some logic that explains this behavior but I cannot detect it...

EDIT: It seems to be related to the way the rectangles are initially created (whether drawn individually or copied), and probably also the order. But as shown above, both methods might require "nudging" and scaling up to have proper fitting. The tiles seem to "remember" some of the pattern history and might behave a bit oddly when an image is placed, and there might also be something OS specific; but fitting is nevertheless easy, and the control works greatly as an image splitter.

 

 

Link to comment
Share on other sites

Well since it's overall pretty trivial to do such image splittings via scripting etc. too, here is a little python3 script as an example. It will do -what I've shown above in a Java GUI app- for splitting an image into rows x cols pieces, but has to be invoked from a command shell.

If you have an installed "Python3" on your system (Win, MacOS or Linux) you would call it like this from a shell ...

Quote

> python3 splitimage.py imagefile 3 4

...or if you rename it to just "splitimage" instead of "splitimage.py" and give it via chmod +x execution rights, you can call it like an executable...

> splitimage imagefile 3 4

...and it will split the as an argument given "imagefile" according to the given "rows" and "cols" number arguments into (in this case 3x4=12) image pieces. - The image pieces will be generated/placed into same path where the given image file resides!

Here's the Python script code:

#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# splitimage - splits an image into rows x cols pieces
# 
# First do a:
#        pip install Pillow
# or:    
#        python -m pip install Pillow
#
import os
import sys
from PIL import Image

### Prints out the Usage information
def Usage():
    print ("Usage: %s imagefile rows cols" % (sys.argv[0]))
    sys.exit(1)

### Check for the right given arg length
if len(sys.argv) != 4:
    Usage()

src_imgage = sys.argv[1]
rows, cols = int(sys.argv[2]), int(sys.argv[3])


### The splitimage function
def splitimage(input, xPieces, yPieces):
    filename, file_extension = os.path.splitext(input)
    im = Image.open(input)
    imgwidth, imgheight = im.size
    height = imgheight // yPieces
    width = imgwidth // xPieces
    for i in range(0, yPieces):
        for j in range(0, xPieces):
            box = (j * width, i * height, (j + 1) * width, (i + 1) * height)
            a = im.crop(box)
            try:
                a.save("" + filename + "-" + str(i) + "-" + str(j) + file_extension)
            except:
                pass

### The main splitimage function call
splitimage(src_imgage, rows, cols)


And the Python3 script file:

 

 

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

2 hours ago, v_kyr said:

Well since it's overall pretty trivial to do such image splittings via scripting etc. too, ...

Perhaps if you already have Python 3 (& I suppose Pillow as well, right?) installed, don't mind saving the document in a file format the script will work with, then it is trivial. If not, I think the bitmap fill 'in app' approach is probably easier overall.

All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
Affinity Photo 
1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

Link to comment
Share on other sites

47 minutes ago, R C-R said:

Perhaps if you already have Python 3 (& I suppose Pillow as well, right?) installed

If you install Python and make a "pip install Pillow" it takes 1 sec and you have the Pillow package inside the Python context, as far as it's not already included in your Python distribution. The whole takes less time than installing something in Affinity and then fiddling around another hour for setting up some workarounds inside Affinity for such missing functionality, which then finally doesn't work as expected at all.

47 minutes ago, R C-R said:

don't mind saving the document in a file format the script will work with

Not sure what that should mean at all? - The script is plain text so one of the simplest things to deal with here too. The whole is much simpler than dealing with Affinity here, especially if you have to do such image-splittings often again and again in various different splitting forms. - Or if you are not able to use a shell and Python, since it might be beyond your capabilities, well then take some GUI-Tool which internally does the same!

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

Wow, @Wosven and @Hens, thank you! It works! And the group trick will really speed up the workflow! 👍

This is a very useful method that deserves to create a video tutorial. If you post your video in the Tutorials section, or on YouTube, it's a good contribution!

Link to comment
Share on other sites

On 11/15/2021 at 2:20 PM, Hens said:

but you'll need to manually adjust to make it fit
If grouped you simply wiggle the centre node and the bitmap fill will adjust in one go

I created this set of Mah Jong tiles and could now reproduce what you mention, both on macOS and Windows. Grouping is especially useful if there is need to have an exact match (place a raster image to a matching rectangle grid) and starting from the 0,0 origin, since the fill tool works from center to outwards and is not ideal when needing to scale exactly something from the (top left) corner. When I initially tested the feature with a 12x12 inch grid (with 144 rectangles) filling the grid ungrouped or grouped always behaved identically, no matter which size of bitmaps were used. I have no idea how this was achieved but I cannot reproduce this now with a fresh file, but the mentioned file still behaves that way.  

Anyway, this tile set was created within a few minutes using first distribution alignment, then the Corner Tool, 3D Fx and Outer Shadow Fx, all in one go, and would be ready to be used e.g. in Publisher in a handbook, but could be exported with few more clicks (shadows turned off on a single click) to e.g. separate PNGs with transparency, PDFs or SVGs to be used in other apps. 

 

Link to comment
Share on other sites

Here is that "odd" macOS version Designer file that I used initially:

 

It always scales the image to full width, similarly as when using a grouped grid of rectangles. Affinity apps typically "remember" last used settings, but I do not seem to be able to make them remember this desired behavior again...

Link to comment
Share on other sites

15 hours ago, v_kyr said:

If you install Python and make a "pip install Pillow" it takes 1 sec and you have the Pillow package inside the Python context, as far as it's not already included in your Python distribution.

I guess I do not have the correct version of Python installed on my Mac because I get a message that the pip command is not found. So I would have to spend time figuring out how to fix that before going any further.

15 hours ago, v_kyr said:

Not sure what that should mean at all? - The script is plain text so one of the simplest things to deal with here too.

What I mean is, unless I misunderstood how to use the script, it can't be run on an Affinity format document, so I would first have to export my Affinity file to a format the script can work with, & then (if I wanted to do any more work on the Affinity version) import that back into Affinity. That is several steps, including at least one that requires disk space.

Do I have that wrong?

All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
Affinity Photo 
1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

Link to comment
Share on other sites

15 hours ago, v_kyr said:

The whole is much simpler than dealing with Affinity here, especially if you have to do such image-splittings often again and again in various different splitting forms.

Does the script provide any way to deal with splitting images if the split pieces need to be stretched, rotated, or otherwise modified for some project? I think that could be done fairly easily using the 'in-app' bitmap fill technique, but of course the grid of shapes would need to be set up for each grid with different rows & columns.

OTOH, if only one or a few grid configurations were routinely needed, maybe saving a few of them as Affinity templates or assets would simplify things considerably.

All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
Affinity Photo 
1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

Link to comment
Share on other sites

36 minutes ago, R C-R said:

I guess I do not have the correct version of Python installed on my Mac because I get a message that the pip command is not found.

If you get such a message, but you have Python already installed, then open the Terminal.app and type in ...

  • pip install Pillow

... this should install the Pillow package immediately into your Python installation context, so Python afterwards should know and find it !

36 minutes ago, R C-R said:

What I mean is, unless I misunderstood how to use the script, it can't be run on an Affinity format document ...

As a long time Affinity user you should already know that there is no support for the proprietary Affinity file format! So how should it deal with that (?), there is no third party app or tool so far which does so. AFAIK nobody fully reverse-engineered the Affinity file format yet. - But that script can deal with common JPG/PNG image files and split those, which in turn can be opened/loaded into Affinity apps.

And if you want more comfort here, you can enhance that script so it performs/executes a ...

  • open -a "Affinity Designer" splitted-filenames*.png

... at the end etc.

 

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

44 minutes ago, R C-R said:

Does the script provide any way to deal with splitting images if the split pieces need to be stretched, rotated, or otherwise modified for some project?

You can add that functionality too if you like, so far I for my part just coded quickly a 45 lines script where 14 lines from are comments and 8 lines are newlines, the later just for an overall better code read overview for people like you. So from those 45 lines, just 23 lines are real code, for what the OP wanted initially to do, but in a quicker to handle and more flexible manner here, without drawing grids and thinking about their exact pixel or possible shifts etc.!

You can also just use ImageMagick, which can do thousends things more here in a quickly usable manner!

 

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

30 minutes ago, v_kyr said:

If you get such a message, but you have Python already installed, then open the Terminal.app and type in ...

  • pip install Pillow

Like I said, for me that results in a pip command not found notice. I think this is probably because I just have an older Python (2.7?) version installed on my Mac. I searched for an up-to-date 3.x version but the installer mentioned needed to change certain permissions (or something like that) after installing it. For now, I am not willing to do that, so I bailed on the install.

35 minutes ago, v_kyr said:

As a long time Affinity user you should already know that there is no support for the proprietary Affinity file format! So how should it deal with that (?), there is no third party app or tool so far which does so.

That is exactly the point I was trying to make about the limitations of using a script vs. an 'in-app' solution, specifically the bitmap fill method. It does not require exporting anything if the work is currently stored in the Affinity format. Among other things it allows exporting of just selected slices; exporting to any supported format; using all the Export persona options in AD or AP, & interactive stretching if required or desired.

All I am saying is your script method may be much simpler for some uses but for others not so much.

All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
Affinity Photo 
1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

Link to comment
Share on other sites

41 minutes ago, R C-R said:

I searched for an up-to-date 3.x version but the installer mentioned needed to change certain permissions (or something like that) after installing it. For now, I am not willing to do that, so I bailed on the install.

You may have Python 3 installed but it won't be the default, 2point whatever is the default (I think it is/was, could be wrong). 

Try this: in the terminal type python3

327669029_ScreenShot2021-11-16at10_51_31AM.png.b1b2d6cad87a6e6d0134a31fad7d866c.png

If Python 3 is installed it will run only when python3 is typed in until we make a bunch of changes to a bunch of stuff.

But yes I agree about python being simpler for some and not others.

I really don't like going down into rabbit holes with something named Python.

Mac Pro (Late 2013) Mac OS 12.7.4 
Affinity Designer 2.4.1 | Affinity Photo 2.4.1 | Affinity Publisher 2.4.1 | Beta versions as they appear.

I have never mastered color management, period, so I cannot help with that.

Link to comment
Share on other sites

10 minutes ago, R C-R said:

Like I said, for me that results in a pip command not found notice. I think this is probably because I just have an older Python (2.7?) version installed on my Mac.

v.2.7 uuh yes that's stone age, that's a very very old Python installation, see related to that very old Python version the following for Pillow:

15 minutes ago, R C-R said:

I searched for an up-to-date 3.x version but the installer mentioned needed to change certain permissions (or something like that) after installing it. For now, I am not willing to do that, so I bailed on the install.

That's usually no problem, since it installs the newer one into "/usr/local/bin" not conflicting with Apple's old Python 2.7 which resides in "/usr/bin/python".

Quote

> which python
/usr/bin/python

> python --version
Python 2.7.10

Further the newer Python 3.x version one will also be named python3 ...

Quote

> which python3
/usr/local/bin/python3

> python3 --version
Python 3.9.1

So you can usually safely do so. - Another way is to install via Homebrew a version 3.9!

 

27 minutes ago, R C-R said:

That is exactly the point I was trying to make about the limitations of using a script vs. an 'in-app' solution, specifically the bitmap fill method. It does not require exporting anything if the work is currently stored in the Affinity format. Among other things it allows exporting of just selected slices; exporting to any supported format; using all the Export persona options in AD or AP, & interactive stretching if required or desired.

All I am saying is your script method may be much simpler for some uses but for others not so much.

The Affinity format isn't usable outside of Affinity and Affinity itself also doesn't export to so many file formats. Further it even doesn't import/export into some in a very good manner (like SVG, EPS, AI, PSD) and so has it's weaknesses here in contrast to some other tools. - The above mentioned ImageMagick for example partly does a much better job here and also supports by far much more file formats it can convert vis-versa than Affinity.

The Python script I've shown above is a quick & fast turnaround solution, for just a table based "row x column" files parts splitting, nothing more. It allows you to quickly split common JPG/PNG images into parts. - And I claim here, that before anyone even built a 4 x 8 grid or so the right way sized up in Affinity, I've already split >= 20 images with such a script into the peaces I may need. - That is the essential point for me, do not dwell long around with such peanuts things. Because in my daily dev working domain time is money and my customers don't pay me for twiddling around 6 hours in Affinity, for things you can have usually done in 30 minutes!

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

7 minutes ago, Old Bruce said:

Try this: in the terminal type python3

I get an 'xcrun' error:

Quote

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

So from what I read elsewhere on the web, my problem begins with the developer tools not being installed on my Mac. There is a solution for that but it just adds to the number of things I would have to do before I could use the script.

All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
Affinity Photo 
1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

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.