-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brandon Berhent
committed
Sep 3, 2022
1 parent
b78aba3
commit e0887ba
Showing
7 changed files
with
64 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package image | ||
|
||
import ( | ||
"errors" | ||
"sync" | ||
|
||
"github.com/h2non/bimg" | ||
) | ||
|
||
type ImageFormat string | ||
|
||
type ImageConverter struct { | ||
mutex sync.Mutex | ||
} | ||
|
||
func (c *ImageConverter) ConvertSvgToBinary(svgData []byte, format bimg.ImageType, size uint) ([]byte, error) { | ||
c.mutex.Lock() | ||
defer c.mutex.Unlock() | ||
inputImage := bimg.NewImage(svgData) | ||
if inputImage == nil { | ||
return nil, errors.New("Unable to load svg for rasterization") | ||
} | ||
|
||
op := bimg.Options{ | ||
Width: int(size), | ||
Height: int(size), | ||
Type: format, | ||
StripMetadata: true, | ||
} | ||
processed, err := inputImage.Process(op) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return processed, nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters