Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

public methods and variables to be able to use picfit as library #117

Merged
merged 1 commit into from
May 31, 2019

Conversation

theromis
Copy link
Contributor

@theromis theromis commented May 29, 2019

I'm using picfit as a library (same way as django-sorl-thumbnail) to generate thumbnails on remote GCS storage, after last update my code stopped working. So I think this changes can be useful not only for me :)

func processImage(processor *picfit.Processor, qs map[string]interface{}, storeKey string, async bool) (*image.ImageFile, error) {

    file := &image.ImageFile{
        Key:     storeKey,
        Storage: processor.DestinationStorage,
        Headers: map[string]string{},
    }

    var filepath string

    var err error

    // URL provided we use http protocol to retrieve it
    filepath = qs["path"].(string)
    if !processor.SourceStorage.Exists(filepath) {
        return nil, failure.ErrFileNotExists
    }

    file, err = image.FromStorage(processor.SourceStorage, filepath)
    if err != nil {
        return nil, err
    }

    parameters, err := processor.NewParameters(file, qs)
    if err != nil {
        return nil, err
    }

    file, err = processor.Engine.Transform(parameters.Output, parameters.Operations)
    if err != nil {
        return nil, err
    }

@thoas thoas merged commit e6ba038 into thoas:master May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants