add detailed jpg quality opts & thumbnail pass
Docker server image / build-and-push (push) Successful in 3m48s
Docker server image / build-and-push (push) Successful in 3m48s
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user