Skip to content

Commit a69826a

Browse files
Methode de constrate fonctionnel
1 parent c367b9b commit a69826a

19 files changed

Lines changed: 345 additions & 142 deletions

File tree

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Byte-compiled / optimized / DLL files
2-
__pycache__/
2+
*__pycache__/*
3+
*/__pycache__/
4+
__pycache__/*
5+
migrations/*
6+
*/migrations/
7+
*/static/imageprocess/images/
38
*.py[cod]
49
*$py.class
510

imageprocess/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
'django.contrib.sessions',
3838
'django.contrib.messages',
3939
'django.contrib.staticfiles',
40+
'imgprocess.apps.ImgprocessConfig'
4041
]
4142

4243
MIDDLEWARE = [

imageprocess/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
from django.contrib import admin
33
from django.urls import path,include
4-
from improcess import views as imgviews
4+
from imgprocess import views as imgviews
55

66
urlpatterns = [
77
path("",imgviews.index,name="home"),
8-
path("process/",include("imageprocess.urls")),
8+
path("process/",include("imgprocess.urls")),
99
path('admin/', admin.site.urls),
1010
]

imgprocess/img_api.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from django.http import JsonResponse
2+
from django.shortcuts import render
3+
from django.http import HttpResponseRedirect
4+
5+
import os
6+
from .form import UploadFileForm
7+
from .utils.img_lib import ImgLib
8+
from .utils.utility import *
9+
from PIL import Image
10+
import numpy as np
11+
12+
def _constrate(request):
13+
image_file=request.FILES["imguploaded"]
14+
#print(str(image_file))
15+
file_name,file_extension=os.path.splitext(str(image_file))
16+
saved_name=get_random_string(15)+file_extension
17+
#we save file to the disk
18+
handle_uploaded_file(request.FILES['imguploaded'],"imgprocess/static/imageprocess/images/"+saved_name)
19+
#file_name,file_extension="bonjour",".jpeg"
20+
imgglib=ImgLib()
21+
img_final=Image.open("imgprocess/static/imageprocess/images/"+saved_name)
22+
img_matrix=np.reshape(list(img_final.getdata()),img_final.size)
23+
#print(img_matrix.shape)
24+
#img_matrix=imgglib.get_image_matrix("imgprocess/static/imageprocess/images/"+saved_name)
25+
saturation_min=int(request.POST["saturation-min"])
26+
saturation_max=int(request.POST["saturation-max"])
27+
28+
#appel de la tranformation lineaire
29+
final_matrix=imgglib.linea_transformation(img_matrix,saturation_min,saturation_max)
30+
#final_matrix=np.reshape(final_matrix,(final_matrix.shape[0]*final_matrix.shape[1]))
31+
img=Image.fromarray(final_matrix.astype(np.uint8))
32+
#maintenant nous devons creer un nom pour notre fichier
33+
34+
img.save("imgprocess/static/imageprocess/images/result/"+saved_name)
35+
return JsonResponse({"original_name":str(image_file),"extention":file_extension,"saved_name":saved_name})
36+
37+
def _egalisation_histogramme(request):
38+
return JsonResponse({"status":True})
-63.8 KB
Binary file not shown.

imgprocess/static/shared/css/imageprocess.css

Lines changed: 25 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -22,122 +22,34 @@ h1, h2, h3, h4, h5, h6, .worksans, .worksans * {
2222
font-family: 'Work Sans', sans-serif !important;
2323
}
2424

25-
.main-color {
26-
background-color: #060d3b;
27-
background-color: rgb(6, 13, 59);
28-
}
29-
30-
.second-color {
31-
background-color: #c73434;
32-
background-color: rgb(199, 52, 52);
33-
}
34-
35-
.second-color-text, .second-color-text a, .second-color-text.navbar-nav .nav-link {
36-
color: rgb(199, 52, 52);
37-
}
38-
39-
.main-color-text, .main-color-text a, .main-color-text.navbar-nav .nav-link {
40-
color: #060d3b;
41-
}
42-
43-
.third-color {
44-
background-color: #a1a1a1;
45-
background-color: rgb(161, 161, 161);
46-
}
47-
.stat-card .row .card {
48-
height: 150px;
49-
vertical-align: middle;
50-
text-align: center;
51-
padding-top: 25%;
52-
margin-top: 25px;
53-
margin-bottom: 25px;
54-
}
55-
::placeholder{
56-
color: #BaB3B3 !important;
57-
color : rgba(186,179,179,0.7) !important;
58-
}
59-
60-
input:focus{
61-
border-top: 0px ;
62-
border-left: 0px ;
63-
border-right: 0px ;
64-
border-bottom: 2px ;
65-
border-bottom-color:#060d3b;
66-
67-
}
68-
69-
.title-text {
70-
text-align: justify;
71-
text-decoration: white;
72-
text-shadow: #060d3b;
73-
font-size: 40px;
74-
font-family: Georgia, 'Times New Roman', Times, serif;
75-
margin: 10px;
76-
77-
}
78-
.next:hover{
79-
background-color: #060d3b;
25+
.image-preview,.btn-image-previews,.btn-image-preview{
26+
display: block !important;
27+
width: 100px !important;
28+
height: 100px !important;
29+
border-radius: 4px !important;
30+
border: 1px solid #ebebeb !important;
31+
background-color:#eeeeee !important;
32+
box-shadow: none !important;
8033
}
81-
.border-right-none{
82-
border-right-width: 0px;
34+
label.btn-image-preview{
35+
line-height: 100px !important;
36+
text-align:center;
37+
font-size:48px !important;
8338
}
84-
.border-left-none
85-
{
86-
border-left-width: 0px;
39+
.btn-image-previews{
40+
line-height: 100px !important;
41+
text-align:center;
42+
font-size:48px !important;
43+
background-color:#1d0e1d !important;
8744
}
88-
.already:hover{
89-
color: #c73434 ;
90-
45+
.remove_image{
46+
font-size: 24px;
47+
font-style: normal;
48+
font-weight: bolder;
49+
cursor: pointer;
9150
}
9251

93-
@media(min-width:768px)
94-
{
95-
.logo_blanc{
96-
margin-top: 0px;
97-
top: 0px;
98-
99-
}
100-
.row
101-
{
102-
margin-top: 20px;
103-
}
104-
.white-part
105-
{
106-
top: 0px;
107-
}
108-
body
109-
{
110-
width: 100%;
111-
}
112-
113-
}
114-
.inputLogin {
115-
116-
padding-left: 3rem;
117-
border-left: 1px solid rgb(206, 212, 218) !important;
118-
border-top-left-radius: 4px !important;
119-
border-bottom-left-radius: 4px !important;
120-
transition: 0.2s ease-in border;
121-
}
122-
.inputLogin:focus {
123-
box-shadow: none !important;
124-
border-bottom: 1px solid #060d3bb3;
125-
border-left: none !important;
126-
/* border-top-left-radius: 4px !important; */
127-
border-radius: 0px !important;
128-
}
129-
.iconLogin {
130-
position: absolute;
131-
top: 10px;
132-
left: 10px;
133-
z-index: 5;
134-
color: #060d3b;
135-
}
136-
.inputloginGroup{
137-
position: relative;
138-
}
139-
.yoyo {
140-
margin-top: -2rem;
141-
margin-left: -3.2rem;
142-
transform: rotate(14deg);
52+
.img-list-work .card{
53+
height: 300px;
54+
background-color: #eeeeee;
14355
}

imgprocess/static/shared/js/anavi.js

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
function showPreview(objFileInput,html_element) {
2+
if (objFileInput.files[0]) {
3+
var fileReader = new FileReader();
4+
fileReader.onload = function (e) {
5+
$(html_element).html('<img src="'+e.target.result+'" width="100%" height="100%" class="upload-preview" />');
6+
}
7+
fileReader.readAsDataURL(objFileInput.files[0]);
8+
}
9+
}
10+
11+
12+
$(function(e){
13+
$("#form_upload_image").submit(function(r){
14+
form_data=new FormData(this)
15+
$.ajax({
16+
url:$(this).attr("action"),
17+
data:form_data,
18+
contentType: false,
19+
cache: false,
20+
processData: false,
21+
dataType: "json",
22+
method:"POST",
23+
success:function(result){
24+
console.log("bonjour")
25+
$("#result-box").html("<img src='/static/imageprocess/images/result/"+result["saved_name"]+"' width='100%' height='100%' />");
26+
},
27+
error:function(result){
28+
console.log("error")
29+
}
30+
});
31+
return false;
32+
});
33+
});

imgprocess/templates/base.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<link rel="stylesheet" type="text/css" href="{% static 'shared/css/librairies/bootstrap.min.css' %}" />
77
<link rel="stylesheet" type="text/css" href="{% static 'shared/css/imageprocess.css' %}" />
88
<script type="text/javascript" src="{% static 'shared/js/librairies/jquery-3.5.1.min.js' %}"></script>
9+
<script type="text/javascript" src="{% static 'shared/js/img_process.js' %}"></script>
10+
911
</head>
1012
</head>
1113
<body>

imgprocess/templates/imageprocess/luminecance.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)