AddPicture provides the method to add picture in a sheet by given picture format set (such as offset, scale, aspect ratio setting and print settings) and file path, supported image types: BMP, EMF, EMZ, GIF, ICO, JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ. This function is concurrency-safe. Note t
(sheet, cell, name string, opts *GraphicOptions)
| 193 | // size with cells). If you don't set this parameter, the default positioning |
| 194 | // is to move and size with cells. |
| 195 | func (f *File) AddPicture(sheet, cell, name string, opts *GraphicOptions) error { |
| 196 | var err error |
| 197 | // Check picture exists first. |
| 198 | if _, err = os.Stat(name); os.IsNotExist(err) { |
| 199 | return err |
| 200 | } |
| 201 | ext, ok := supportedImageTypes[strings.ToLower(path.Ext(name))] |
| 202 | if !ok { |
| 203 | return ErrImgExt |
| 204 | } |
| 205 | file, _ := os.ReadFile(filepath.Clean(name)) |
| 206 | return f.AddPictureFromBytes(sheet, cell, &Picture{Extension: ext, File: file, Format: opts}) |
| 207 | } |
| 208 | |
| 209 | // AddPictureFromBytes provides the method to add picture in a sheet by given |
| 210 | // picture format set (such as offset, scale, aspect ratio setting and print |