-
Notifications
You must be signed in to change notification settings - Fork 42
en Image Operations
zero edited this page Jun 5, 2025
·
1 revision
WordZero provides comprehensive image manipulation capabilities for inserting, positioning, and styling images in Word documents. This chapter covers image insertion, sizing, positioning, and advanced image features.
import "github.com/ZeroHawkeye/wordZero/pkg/document"
doc := document.New()
// Insert image from file
image, err := doc.AddImageFromFile("path/to/image.jpg")
if err != nil {
log.Fatal(err)
}
// Insert image from byte data
imageData, _ := ioutil.ReadFile("image.png")
image2 := doc.AddImageFromBytes(imageData)WordZero supports multiple image formats:
// Supported formats
// JPEG/JPG
doc.AddImageFromFile("photo.jpg")
// PNG (with transparency support)
doc.AddImageFromFile("logo.png")
// GIF
doc.AddImageFromFile("animation.gif")
// BMP
doc.AddImageFromFile("bitmap.bmp")// Insert image with original size
image := doc.AddImageFromFile("image.jpg")
// Auto-fit to page width
image.FitToPageWidth()
// Auto-fit to specific width (maintaining aspect ratio)
image.SetWidth(400) // pixels
// Auto-fit to specific height (maintaining aspect ratio)
image.SetHeight(300) // pixels- Use appropriate resolution for your document
- Optimize file sizes for better performance
- Choose the right format for your content
- Ensure images enhance the content
- Use consistent sizing throughout the document
- Consider text flow around images
- Provide alternative text for images
- Ensure sufficient contrast
- Use images that support your message
Continue learning about document features:
- Advanced Features - Complex document elements
- Best Practices - Optimization techniques
- Template Features - Dynamic content
Master image operations to create visually appealing documents!