Hi,
I do have huge image local storage
/var/discourse/shared/standalone/uploads/default
57.5GiB [##########] /original
35.6GiB [###### ] /optimized
the original
56.7GiB [##########] /3X
667.6MiB [ ] /2X
155.5MiB [ ] /1X
and optimized
33.8GiB [##########] /3X
1.7GiB [ ] /2X
113.3MiB [ ] /1X
I found this settings and make this 1 and 2. Is it relevant settings?
I would like to drop all 3X images (original and optimized) and store/show only 2X picture?
How to setup this configuration?
T H A N K S
sam
(Sam Saffron)
21 مايو 2019، 11:25م
2
3x is just a naming convention it has nothing to do with image size
If you want to cut on storage you could run the rake task that irreversibly shrinks old images and drops fidelity
how to do it? what’s the command line?
sam
(Sam Saffron)
24 يونيو 2019، 7:09ص
4
This script should do it:
# frozen_string_literal: true
require File.expand_path("../../config/environment", __FILE__)
# no less than 1 megapixel
max_image_pixels = [ARGV[0].to_i, 1_000_000].max
puts '', "Downsizing uploads size to no more than #{max_image_pixels} pixels"
count = 0
Upload.where("lower(extension) in (?)", ['jpg', 'jpeg', 'gif', 'png']).find_each do |upload|
count += 1
print "\r%8d".freeze % count
absolute_path = Discourse.store.path_for(upload)
if absolute_path && FileHelper.is_supported_image?(upload.original_filename)
file = File.new(absolute_path) rescue nil
next unless file
image_info = FastImage.new(file) rescue nil
This file has been truncated. show original
But I would be very very careful to have a full backup of everything prior to playing with it.
/var/discourse/shared/standalone/uploads/default
57.5 جيغابايت [##########] /original
35.6 جيغابايت [###### ] /optimized
يرجى إخباري بأي مجلد، /original أم /optimized، يمكنني حذفه لتوفير مساحة؟
كما ذكر @sam ، إذا كنت ترغب حقًا في تقليل استخدام القرص، فستحتاج إلى تصغير جميع الملفات الأصلية وإعادة توليد جميع الصور المصغرة (أي الصور “المُحسَّنة”).
هذه عملية متشعبة لأنك يجب أن تقوم بتحديث الملفات على القرص والسجلات المرتبطة بها في قاعدة البيانات.
يا إلهي!
لقد أفسدت مجلد /original للتو أثناء نقله من مجلد إلى آخر.
هل هناك طريقة لاستخدام الصور من مجلد /optimized؟ أم من قاعدة بيانات Postgres؟
هل أنا في ورطة الآن؟
هل هناك أي تلميحات أو نقاط؟
sam
(Sam Saffron)
30 يونيو 2019، 10:38ص
9
يمكنك محاولة الاستعادة من النسخة المحسّنة، لكن الجودة ستكون محدودة
إذا كان لديك نسخة احتياطية تتضمن ملفات مرفقة، فيمكنك استخراجها مباشرة من الأرشيف في مجلد “الأصلية”.
كيف يمكنني فعل ذلك؟ لدي مجلد /optimized بالكامل.
أقوم بنسخ احتياطي للمحتوى فقط دون ملفات مُحمَّلة.
هل يجب أن أنسخ ببساطة /optimized إلى /original؟
sam
(Sam Saffron)
1 يوليو 2019، 12:01ص
14
انظر إلى:
./launcher enter app
rails c
Upload.last(10)
لاحظ الروابط الموجودة هناك، فهذا هو المكان الذي نتوقع فيه وجود التحميلات.
root@dastereo:/var/postgres_data_discourse# du -hs * | sort -rh | head -5
33G base
129M pg_wal
46M pg_xact
616K global
216K pg_subtrans
هل تحتوي قاعدة بيانات PostgreSQL على صور أيضًا؟ هل هذا مقبول؟
تُخزَّن جميع الملفات على القرص، بينما يحتوي قاعدة البيانات فقط على سجلات لبعض البيانات الوصفية.