Skip to content

Commit

Permalink
issue with photo
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiboutas committed Jan 24, 2024
1 parent 775ff11 commit 4ab8667
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
23 changes: 8 additions & 15 deletions core/models/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,21 +449,20 @@ def crop_photo(self):

def process_photo(self):
if self.full_photo:
size_modified = False
try:
img = Image.open(self.full_photo)
except Exception as e:
raise e

if img.height > 1200 or img.width > 1200:
new_size = (1200, 1200)
img.thumbnail(new_size)
img.save(self.full_photo.path)
size_modified = True
# if img.height > 1200 or img.width > 1200:
# new_size = (1200, 1200)
# img.thumbnail(new_size)
# img.save(self.full_photo.path)
# size_modified = True

if not self.cropped_photo:
if size_modified:
img = Image.open(self.full_photo)
# if size_modified:
# img = Image.open(self.full_photo)
distance = int(0.95 * min([img.height, img.width]))
self.crop_width, self.crop_height = distance, distance
self.crop_x = int((img.width - distance) / 2)
Expand All @@ -475,13 +474,7 @@ def has_photo(self):
to_check = getattr(getattr(self, "cropped_photo"), "name")
return to_check != "" and to_check is not None

@cached_property
def photo_path_old(self):
if self.has_photo:
return self.cropped_photo.path

@cached_property
def photo_path(self):
def get_photo_path(self):
if self.has_photo:
self.cropped_photo.seek(0)
photobytes = self.cropped_photo.read()
Expand Down
2 changes: 1 addition & 1 deletion tex_templates/cvs/Alice/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
%----------------------------------------------------------------------------------------
% photo
{% if profile.has_photo and profile.photo_active %}
\photo{\includegraphics[width=\imagewidth]{ {{- profile.photo_path -}} } }
\photo{\includegraphics[width=\imagewidth]{ {{- profile.get_photo_path() -}} } }
{% else %}
\photo{}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion tex_templates/cvs/Krieger/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
{% endif %}
% photo
{% if profile.has_photo and profile.photo_active %}
\photo[round]{ {{- profile.photo_path -}} }{\dimexpr \headerheight-\marginbottom} % Profile picture
\photo[round]{ {{- profile.get_photo_path() -}} }{\dimexpr \headerheight-\marginbottom} % Profile picture
{% else %}
\photo[round]{picture.jpg}{\dimexpr \headerheight-\marginbottom} % Profile picture
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion tex_templates/cvs/Marissa/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
%% You can add multiple photos on the left (\photoL) or right (\photoR)

{% if profile.has_photo and profile.photo_active %}
\photoR{2.5cm}{ {{- profile.photo_path -}} }
\photoR{2.5cm}{ {{- profile.get_photo_path() -}} }
{% endif %}

\personalinfo{
Expand Down
2 changes: 1 addition & 1 deletion tex_templates/cvs/Modern/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
\usepackage[english]{babel} % FIXME: using spanish breaks moderncv

% personal data
\name{John}{Doe}
\name{ {{- profile.get_tex_value("fullname") -}} }{}
\title{Résumé title} % optional, remove / comment the line if not wanted
\born{4 July 1776} % optional, remove / comment the line if not wanted
\address{street and number}{postcode city}{country}% optional, remove / comment the line if not wanted; the "postcode city" and "country" arguments can be omitted or provided empty
Expand Down

0 comments on commit 4ab8667

Please sign in to comment.