How to cut an image into pieces

I have an image (slice of bytes) how to cut the image into 8 halves, should I just cut the slice into 8 equal pieces?

2 Likes

If you get 8, they aren’t halfes anymore :smiley:

And if you can simply into 8 equal subslices of the bigger one is not easy to tell.

It totally depends on what 8 “halfes” you want to get and how the data is organised in that slice.

Usually you get row after row, so if, and only if, you have a rowcount that is dividable by 8, you can then simply subslice, to get horizontal stripes of the picture.

3 Likes

I have a server where I want to accept an image cut it into smaller pieces and store inside the database, how can I corp images in golang, is it a good decision just to cut the original slice of bytes? about halves hahahhaha you’re right )) my bad xD

2 Likes

You can use the image package to load the image, then use the SubImage method to grab your crop rectangles, and save those.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.