Skip to content
Snippets Groups Projects
Commit fc98bf5f authored by Siranjeevi K's avatar Siranjeevi K
Browse files

inital commit

parent c8606d3e
Branches
No related tags found
No related merge requests found
Showing with 204 additions and 0 deletions
from xlrd import open_workbook
import os;
import string
class Arm(object):
def __init__(self,Name, Department, Role):
self.Name = Name
self.Department = Department
self.Role=Role
path = os.getcwd()
if os.path.exists('files'):
for files in os.listdir('files'):
os.chdir(path+"/files")
os.remove(files)
os.chdir(path)
#file = raw_input("Enter the file name: ")
#wb = open_workbook(file+'.xlsx')
wb = open_workbook('pr.xlsx')
for sheet in wb.sheets():
number_of_rows = sheet.nrows
number_of_columns = sheet.ncols
items = []
rows = []
for row in range(0, number_of_rows):
values = []
for col in range(number_of_columns):
value = (sheet.cell(row,col).value)
try:
value = str(int(value))
except ValueError:
pass
finally:
values.append(value)
item = Arm(*values)
items.append(item)
a='';
b='';
c='';
d='';
for item in items:
a=a+"{0}".format(item.Name).replace('%','')+'.jpg%';
tmp_name = string.capwords(string.replace(item.Name, '.', ' '), ' ').strip()
b=b+"{0}".format(tmp_name).replace('%','')+'%';
c=c+"{0}".format(item.Department).replace('%','')+'%';
d=d+"{0}".format(item.Role).replace('%','')+'%';
a=a[0:len(a)-1];
b=b[0:len(b)-1];
c=c[0:len(c)-1];
d=d[0:len(d)-1];
if not os.path.exists('files'):
os.makedirs('files')
os.chdir(os.getcwd()+'/files')
fi=open('photo_id.txt',"w");
fi.write(a);
fi.close();
fi=open('names.txt',"w");
fi.write(b);
fi.close();
fi=open('roles.txt',"w");
fi.write(c);
fi.close();
fi=open('dept.txt',"w");
fi.write(d);
fi.close();
File added
function cr(path)
{
//app.activeDocument.activeLayer.duplicate();
var doc=app.activeDocument;
file = new File(path);
try
{
var curr_file = app.open(file); // error = file format (change to jpg)
curr_file.selection.selectAll();
curr_file.selection.copy();
curr_file.close(SaveOptions.DONOTSAVECHANGES);
doc.paste();
return true;
}catch(e){
return false;
}
}
function read_s(a)
{
var b = new File(a);
b.open('r');
var str = "";
while(!b.eof)
str += b.readln();
b.close();
return str;
}
var thisFile = new File($.fileName);
var basePath = thisFile.path;
var res1=read_s(basePath+"/ExcelScript/files/names.txt");
var names = res1.split("%");
res1=read_s(basePath+"/ExcelScript/files/dept.txt");
var dept=res1.split("%");
res1=read_s(basePath+"/ExcelScript/files/roles.txt");
var role=res1.split("%");
res1=read_s(basePath+"/ExcelScript/files/photo_id.txt");
var photo=res1.split("%");
var i;
for(i=0;i<names.length;i++)
{
if(role[i]=="Head")
{
var fileRef = new File(basePath+"/templates/head.psd")
}
else if(role[i]=="Co Head")
{
var fileRef = new File(basePath+"/templates/cohead.psd")
}
else
{
var fileRef = new File(basePath+"/templates/rest.psd")
}
var docRef = app.open (fileRef) // error = target application wrong (change to Adobe Photoshop CS6)
var doc = app.activeDocument;
if(!cr(basePath+ '/photos/' +photo[i])){
$.writeln(names[i]+"-"+i+" : Skipped");
continue;
}
doc.layerSets.getByName("Text").artLayers.getByName("NAME").textItem.contents=names[i];
doc.layerSets.getByName("Text").artLayers.getByName("Post").textItem.contents=role[i];
doc.layerSets.getByName("Text").artLayers.getByName("Department").textItem.contents=dept[i];
var opts, pngFile;
opts = new PhotoshopSaveOptions();
pngFile = new File(basePath+"/outputs/psd/"+names[i]+".psd");
app.activeDocument.saveAs(pngFile, opts,true);
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
$.writeln(names[i]+"-"+i);
}
\ No newline at end of file
# ID card generator for Anokha
Script used by Planning and resources committee for generating ID cards.
## Dependencies
+ xlrd (python library to handle MS Excel files)
+ Adobe photoshop
\ No newline at end of file
Save.jsx 0 → 100644
function read_s(a)
{
var b = new File(a);
b.open('r');
var str = "";
while(!b.eof)
str += b.readln();
b.close();
return str;
}
var thisFile = new File($.fileName);
var basePath = thisFile.path;
var res1=read_s(basePath+"/ExcelScript/files/names.txt");
var names = res1.split("%");
var i;
for(i=0;i<names.length;i++)
{
try{
var fileRef = new File(basePath+"/outputs/psd/" + names[i] + ".psd")
var docRef = app.open (fileRef) // error = target application wrong (change to Adobe Photoshop CS6)
}catch(e){
$.writeln(names[i]+"-"+i+" : Skipped");
continue;
}
var doc = app.activeDocument;
jpgFile = new File(basePath+"/outputs/id/" + names[i] + ".jpg");
jpgSaveOptions = new JPEGSaveOptions()
jpgSaveOptions.embedColorProfile = true
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE
jpgSaveOptions.matte = MatteType.NONE
jpgSaveOptions.quality = 12
app.activeDocument.saveAs(jpgFile, jpgSaveOptions, true,Extension.LOWERCASE)
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
$.writeln(names[i]+"-"+i);
}
\ No newline at end of file
for %i in (*.jpg) do @echo %~ni>>1.xls
for %i in (*.*) do @echo %~ni>>1.xls
\ No newline at end of file
photos/.V.seetha Rammaiah.jpg

55.1 KiB

photos/ANUSHA REDDY.jpg

91.9 KiB

photos/Anurag.jpg

111 KiB

photos/Arvind co-head hyd.jpg

239 KiB

photos/B.RAVI TEJA.JPG

6.5 MiB

photos/HASRITHA.jpg

64.6 KiB

photos/Imthiyaz - CIE15022.jpg

49.1 KiB

photos/J.AKHIL.jpg

122 KiB

photos/J.SINDHU.jpg

163 KiB

photos/JHO SRIKAR.jpg

115 KiB

photos/K.M.NIHARIKHA.jpg

2.25 MiB

photos/K.PHANEENDRA.JPG

2.54 MiB

photos/K.S.K Chaitanya - CIE14025.jpg

83 KiB

photos/L.SRAVYA.jpg

156 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment