How to cut an image into pieces

(AkezhanOb1) #1

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?

How to cut an image into several pieces
(Norbert Melzer) #2

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.

(AkezhanOb1) #3

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

(Jakob Borg) #4

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

(system) closed #5

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