forked from janczizikow/sleek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
img_script.m
41 lines (27 loc) · 1.03 KB
/
img_script.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% source image should be aspect ratio 1920 wide x 1080 tall
name = 'Zhiwen';
type = 'people';
% name = 'WRF';
% type = 'posts';
% rootDir = '/Users/nicksteinmetz/Dropbox/code/SteinmetzLab.github.io/';
rootDir = fullfile(dropboxDir, 'code','SteinmetzLab.github.io');
sourceDir = fullfile(rootDir, '_img', type);
targetDir = fullfile(rootDir, 'assets', 'img', type);
d = dir(fullfile(sourceDir, [name '.*']));
q = imread(fullfile(sourceDir, d(1).name));
figure; image(q); axis image;
widthVals = [230 535 535*2 575 767 991 1999 1920];
names = {'_placehold', '_thumb', '_thumb@2x', '_xs', '_sm', '_md', '_lg', ''};
for ii = 1:numel(widthVals)
x = widthVals(ii);
sc = x/size(q,2);
b = imresize(q, sc);
outFile = fullfile(targetDir, [name names{ii} '.jpg']);
fprintf(1, 'Writing width %d to %s\n', x, outFile);
imwrite(b, outFile, 'jpg', 'Quality', 70);
end
% making transparent parts white instead of black
% for idx = 1:3
% newq = 255*ones(size(q,1), size(q,2));
% q1 = q(:,:,idx); newq(~iswhite) = q1(~iswhite); q(:,:,idx) = newq;
% end