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

Does not save watermark in FILE_STORAGE_BASE_DIR #428

Open
AlekseyArh opened this issue Apr 3, 2024 · 6 comments
Open

Does not save watermark in FILE_STORAGE_BASE_DIR #428

AlekseyArh opened this issue Apr 3, 2024 · 6 comments

Comments

@AlekseyArh
Copy link

Hi.

I noticed that imagor does not save the source file used for the watermark.

If you make 3 requests:
/filters:watermark(test/watermark.png,repeat,repeat,0,100,100)/test/1.jpg
/filters:watermark(test/watermark.png,repeat,repeat,1,100,100)/test/1.jpg
/filters:watermark(test/watermark.png,repeat,repeat,2,100,100)/test/1.jpg

access.log s3 will show:

GET /test/1.jpg
GET /test/watermark.png
GET /test/watermark.png
GET /test/watermark.png

Have to pay more for the s3 service due to unnecessary requests =(

@cshum
Copy link
Owner

cshum commented Apr 4, 2024

To understand more on the context, could you please share the environment variables being configured for imagor?
You shall mask any sensitive info such as AWS_SECRET_ACCESS_KEY

@AlekseyArh
Copy link
Author

To understand more on the context, could you please share the environment variables being configured for imagor? You shall mask any sensitive info such as AWS_SECRET_ACCESS_KEY

# IMAGOR_SECRET is a secret key that will help you subscribe to the hashtag links to maps
IMAGOR_SECRET="imagor-secret"
# IMAGOR_SIGNER_TYPE - hashing method and signature uri
IMAGOR_SIGNER_TYPE="sha256"
# IMAGOR_SIGNER_TRUNCATE - the length of the hash in the uri
IMAGOR_SIGNER_TRUNCATE=40
# IMAGOR_STORAGE_PATH_STYLE - the path to the image and its replacement with e6/86/1a810ff186b4f747ef85f7c53946f0e6d8cb
IMAGOR_STORAGE_PATH_STYLE="digest"
# IMAGOR_RESULT_STORAGE_PATH_STYLE - path to files and their replacement with statically deleted files e6/86/1a810ff186b4f747ef85f7c53946f0e6d8cb
IMAGOR_RESULT_STORAGE_PATH_STYLE="digest"
# IMAGOR_REQUEST_TIMEOUT - Maximum time to execute an imagor request
IMAGOR_REQUEST_TIMEOUT=60s
# IMAGOR_PROCESS_CONCURRENCY - A few pros can be recycled daily
IMAGOR_PROCESS_CONCURRENCY=4
# IMAGOR_PROCESS_QUEUE_SIZE - Some information that can be expected today (429 times in a row)
IMAGOR_PROCESS_QUEUE_SIZE=64
# HTTP_LOADER_DEFAULT_SCHEME - as I understand it, this is just an e-book reader application (if there is no HTTP_LOADER_BASE_URL)
HTTP_LOADER_DEFAULT_SCHEME="https"
# Modified sources and base URL
#HTTP_LOADER_ALLOWED_SOURCES=*.example.com
# HTTP_LOADER_BASE_URL - link to the site for any changes
HTTP_LOADER_BASE_URL="https://source.example.com/"
# IMAGOR_UNSAFE is only 1, then you don't need to use a hash to send requests
IMAGOR_UNSAFE=0
# IMAGOR_AUTO_WEBP - if 1, then it will now transmit webp in jpeg format if it does not support webp
IMAGOR_AUTO_WEBP=1
FILE_STORAGE_MKDIR_PERMISSION=0755
FILE_STORE_WRITE_PERMISSION=0666
FILE_STORE_EXPRESSION=24h # not working
FILE_RESULT_RESULT_MKDIR_RESULT=0755
FILE_RESULT_RESULT_RELEASE=0666
EXPIRATION_RESULT_RESULT_FILE=168h
SERVER_ACCESS_LOG=0
VIPS_CONCURRENCY=1

# Maximum allowed image resolution and dimensions
VIPS_MAX_RESOLUTION=225000000
VIPS_max_WIDTH=15000
VIPS_MAX_HEIGHT=15000

@cshum
Copy link
Owner

cshum commented Apr 8, 2024

If you wish activate file storage, FILE_STORAGE_BASE_DIR needs to be present:

https://github.com/cshum/imagor?tab=readme-ov-file#file-system

FILE_STORAGE_BASE_DIR=/mnt/data # enable file storage by specifying base dir
FILE_STORAGE_MKDIR_PERMISSION=0755 # optional
FILE_STORAGE_WRITE_PERMISSION=0666 # optional

@AlekseyArh
Copy link
Author

If you wish activate file storage, FILE_STORAGE_BASE_DIR needs to be present:

https://github.com/cshum/imagor?tab=readme-ov-file#file-system

FILE_STORAGE_BASE_DIR=/mnt/data # enable file storage by specifying base dir
FILE_STORAGE_MKDIR_PERMISSION=0755 # optional
FILE_STORAGE_WRITE_PERMISSION=0666 # optional

Sorry. I have not shown all the settings, this part is written in another file. I completely forgot about him.

However, as I wrote at the beginning, all files except the watermark are saved normally.

        environment:
            PORT: 8000
            IMAGOR_UNSAFE: ${IMAGOR_UNSAFE} # unsafe URL for testing
            IMAGOR_AUTO_WEBP: ${IMAGOR_AUTO_WEBP}
            IMAGOR_SECRET: ${IMAGOR_SECRET}
            IMAGOR_SIGNER_TYPE: ${IMAGOR_SIGNER_TYPE}
            IMAGOR_SIGNER_TRUNCATE: ${IMAGOR_SIGNER_TRUNCATE}
            IMAGOR_STORAGE_PATH_STYLE: ${IMAGOR_STORAGE_PATH_STYLE}
            IMAGOR_RESULT_STORAGE_PATH_STYLE: ${IMAGOR_RESULT_STORAGE_PATH_STYLE}
            IMAGOR_PROCESS_CONCURRENCY: ${IMAGOR_PROCESS_CONCURRENCY} # Maximum number of image process to be executed simultaneously. Requests that exceed this limit are put in the queue. Set -1 for no limit (default -1)
            HTTP_LOADER_DEFAULT_SCHEME: ${HTTP_LOADER_DEFAULT_SCHEME}
            HTTP_LOADER_BASE_URL: ${HTTP_LOADER_BASE_URL}
            FILE_LOADER_BASE_DIR: /mnt/data/source # enable file loader by specifying base dir
            FILE_STORAGE_BASE_DIR: /mnt/data/source # enable file storage by specifying base dir
            FILE_STORAGE_MKDIR_PERMISSION: ${FILE_STORAGE_MKDIR_PERMISSION} # optional
            FILE_STORAGE_WRITE_PERMISSION: ${FILE_STORAGE_WRITE_PERMISSION} # optional
            FILE_RESULT_STORAGE_BASE_DIR: /mnt/data/result # enable file result storage by specifying base dir
            FILE_RESULT_STORAGE_MKDIR_PERMISSION: ${FILE_RESULT_STORAGE_MKDIR_PERMISSION} # optional
            FILE_RESULT_STORAGE_WRITE_PERMISSION: ${FILE_RESULT_STORAGE_WRITE_PERMISSION} # optional
            VIPS_CONCURRENCY: ${VIPS_CONCURRENCY} # VIPS concurrency. Set -1 to be the number of CPU cores (default 1)

@cshum
Copy link
Owner

cshum commented Apr 9, 2024

I see. Yes currently the watermark image gets loaded and does not get saved.

But if it is the same watermark for every images, you may be able to resolve your problem by requesting the watermark image alone

/test/watermark.png

then the subsequence watermark image would be loaded from storage instead.

@AlekseyArh
Copy link
Author

I see. Yes currently the watermark image gets loaded and does not get saved.

But if it is the same watermark for every images, you may be able to resolve your problem by requesting the watermark image alone

/test/watermark.png

then the subsequence watermark image would be loaded from storage instead.

thanks. It really works.
I repeat the request periodically in case the source is cleared:

1 * * * * curl -I https://img-example.com/hash/test/watermark.png --header 'user-agent:imagor-crontab' > /tmp/crontab.imagor.watermark.fix.txt

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

No branches or pull requests

2 participants