add detailed jpg quality opts & thumbnail pass
Docker server image / build-and-push (push) Successful in 3m48s

This commit is contained in:
2026-03-30 05:05:27 -07:00
parent 72d4d521e3
commit 30cbfaadad
10 changed files with 644 additions and 190 deletions
+40 -5
View File
@@ -8,13 +8,25 @@ import (
"time"
"connectrpc.com/connect"
"github.com/segmentio/ksuid"
officeconvertapiv1 "gitea.auvem.com/end-internal/officeconvert/gen/go/officeconvertapi/v1"
"gitea.auvem.com/end-internal/officeconvert/gen/go/officeconvertapi/v1/officeconvertapiv1connect"
"github.com/segmentio/ksuid"
)
const defaultPollInterval = 2 * time.Second
// RasterTierOptions defines per-tier raster settings for conversion output.
type RasterTierOptions struct {
Resolution officeconvertapiv1.ConversionResolution
JPEGQuality int32
}
// CreateConversionOptions configures optional full and thumbnail raster tiers.
type CreateConversionOptions struct {
Full *RasterTierOptions
Thumbnail *RasterTierOptions
}
// Client wraps the generated Connect client with orchestration-focused helpers.
type Client struct {
rpc officeconvertapiv1connect.ConversionServiceClient
@@ -47,12 +59,16 @@ func (c *Client) SetPollInterval(interval time.Duration) {
func (c *Client) CreateConversion(
ctx context.Context,
sourceFilename string,
resolution officeconvertapiv1.ConversionResolution,
options *CreateConversionOptions,
) (*CreateConversionResponse, error) {
req := connect.NewRequest(&officeconvertapiv1.CreateConversionRequest{
message := &officeconvertapiv1.CreateConversionRequest{
SourceFilename: sourceFilename,
Resolution: resolution,
})
}
if options != nil {
message.Full = toProtoSlideRasterOptions(options.Full)
message.Thumbnail = toProtoSlideRasterOptions(options.Thumbnail)
}
req := connect.NewRequest(message)
res, err := c.rpc.CreateConversion(ctx, req)
if err != nil {
return nil, err
@@ -60,6 +76,25 @@ func (c *Client) CreateConversion(
return augmentCreateConversionResponse(res.Msg)
}
func toProtoSlideRasterOptions(
options *RasterTierOptions,
) *officeconvertapiv1.SlideRasterOptions {
if options == nil {
return nil
}
proto := &officeconvertapiv1.SlideRasterOptions{
Resolution: options.Resolution,
}
if options.JPEGQuality != 0 {
proto.Format = &officeconvertapiv1.SlideRasterOptions_Jpeg{
Jpeg: &officeconvertapiv1.JpegOutputOptions{
Quality: options.JPEGQuality,
},
}
}
return proto
}
// StartConversion signals that upload is complete and conversion can begin.
func (c *Client) StartConversion(
ctx context.Context,
@@ -19,7 +19,7 @@ func (c *Client) ConvertPPTXFile(ctx context.Context, localPPTXPath string) (*Co
createRes, err := c.CreateConversion(
ctx,
filepath.Base(localPPTXPath),
officeconvertapiv1.ConversionResolution_CONVERSION_RESOLUTION_UNSPECIFIED,
nil,
)
if err != nil {
return nil, fmt.Errorf("create conversion: %w", err)