What's new

Dynamic Font Size to fit within Box?


katakulli

New Member
Messages
3
Likes
1
Hello,

I hope someone is reading this and has an answer to my problem.

What i want to do:
I have over 300 names (with surnames) listed as a textfile. And i have one image. What i want to do is pasting the text (e.g. name1surname1) on a specific area (which does not change) of the image, and saving the image as jpeg (filename = name1surname1.jpg). Then name2surname2 > saving as name2surname2.jpg, ....
The image is always the same, but the text i have to change (and save-as-jpeg) over 300 times.

As an example:


What my problem is:
I don't have the time to change all 300 names one by one and saving them one by one.
> Using Actions does not solve my problem ofcourse because it is different everytime
> Using Variables (set to the textlayer) and importing datasets COULD solve my problem but:
>> Sometimes one 'name' is longer than the previous one, so it does not fit inside the box:


so i have to change the font size to make it fit again)


What could solve my problem:
A way, which automates all the replacing of the textlayer with the names AND (probably more important) automatically changing the fontsize in case it is too big to fit within the textbox.

I hope there is a way to this. Waiting hopefully for answers thanks in advance!
 
Last edited by a moderator:

IamSam

Administrator
Staff member
Administrator
Messages
16,971
Likes
10,888
Uploading images............

ImageUploadIcon_02.png
 
Last edited:

hawkeye

Guru
Messages
2,266
Likes
1,017
I think you're on the right track with data sets. But instead of a text replacement, save the text as a png with transparency, then define the variable for pixel replacement set to fit the bounding box.
 

katakulli

New Member
Messages
3
Likes
1
I think you're on the right track with data sets. But instead of a text replacement, save the text as a png with transparency, then define the variable for pixel replacement set to fit the bounding box.
Thanks for the good idea, i will definetely try this out.

That would be great for lossless transformation, but it would not help me doing this automatically for each time. The thing is, i want photoshop to do this on its own (resizing) without having to transform each text shape to its place. But thanks for your answer anyway :)
 

SCTRWD

Power User
Messages
449
Likes
226
You can certainly automate this. Create a snapshot of your document in the Actions panel.

Now create an action to place and transform your text :

1. Convert text layer to shapes
2. Make custom shape from the layer(choose some name for it, say, "Name")
3. Delete the layer
4. Draw the "Name" custom shape instance(any size, any place)
5. Transform and move it to fit your bounding box
6. Delete custom shape "Name" from the presets(so that there won't be problems later with the next run of the action)
7. Save

Now go back to your snapshot. Select your text layer. Create data sets for your names(write them in a text file and import). Choose File->Export-> Data sets as files... to save them to some separate folder.

And, finally, File->Automate->Batch... with this folder as input and your action.

This is a bit tricky, but it works:) Besides it lets you add other stuff like Layer styles, etc...

It lets you work around the known problem that Transform command, when written in actions, always use percents for scaling even if you set the linear dimensions in its input boxes:cry:.

Custom shape, on the other hand, lets you place and scale the shapes with pixel dimensions.
 
Last edited:

katakulli

New Member
Messages
3
Likes
1
You can certainly automate this. Create a snapshot of your document in the Actions panel.

Now create an action to place and transform your text :

1. Convert text layer to shapes
2. Make custom shape from the layer(choose some name for it, say, "Name")
3. Delete the layer
4. Draw the "Name" custom shape instance(any size, any place)
5. Transform and move it to fit your bounding box
6. Delete custom shape "Name" from the presets(so that there won't be problems later with the next run of the action)
7. Save

Now go back to your snapshot. Select your text layer. Create data sets for your names(write them in a text file and import). Choose File->Export-> Data sets as files... to save them to some separate folder.

And, finally, File->Automate->Batch... with this folder as input and your action.

This is a bit tricky, but it works:) Besides it lets you add other stuff like Layer styles, etc...

It lets you work around the known problem that Transform command, when written in actions, always use percents for scaling even if you set the linear dimensions in its input boxes:cry:.

Custom shape, on the other hand, lets you place and scale the shapes with pixel dimensions.
You, sir, are my hero! Never ever thought that this would work! Thanks so much! I cant be happier now. :)
 

roschirosch2

New Member
Messages
2
Likes
0
You can certainly automate this. Create a snapshot of your document in the Actions panel.

Now create an action to place and transform your text :

1. Convert text layer to shapes
2. Make custom shape from the layer(choose some name for it, say, "Name")
3. Delete the layer
4. Draw the "Name" custom shape instance(any size, any place)
5. Transform and move it to fit your bounding box
6. Delete custom shape "Name" from the presets(so that there won't be problems later with the next run of the action)
7. Save

Now go back to your snapshot. Select your text layer. Create data sets for your names(write them in a text file and import). Choose File->Export-> Data sets as files... to save them to some separate folder.

And, finally, File->Automate->Batch... with this folder as input and your action.

This is a bit tricky, but it works:) Besides it lets you add other stuff like Layer styles, etc...

It lets you work around the known problem that Transform command, when written in actions, always use percents for scaling even if you set the linear dimensions in its input boxes:cry:.

Custom shape, on the other hand, lets you place and scale the shapes with pixel dimensions.
OK, I open this discussion again :) Thank you SCTRWD for this answer! It works quite well, but I have the following problem: Now my text (which is a custom shape now) has the correct width, but always the same height. This means that most of the results look skewed. Has anyone an idea how to tell my action to keep the correct ratio? Or am I doing something wrong? :)
 

SCTRWD

Power User
Messages
449
Likes
226
Do you have File->Automate->Fit Image... command?
If you do then record simple action:
Make your text layer.
Duplicate layer to new document(Layer->Duplicate layer...)
In the new document choose Image->Trim. Trim transparent pixels on all sides
Now choose File->Automate->Fit Image... In the dialog enter the width and height of the Box
Edit->Copy
Close new image, this should bring you back to the original image
Delete current layer, you do not need old text
Edit->Paste
Now make selection of the box layer (Ctrl click on it's icon), make sure the text layer is selected in the Layers panel and
choose Layer->Align Layers to selection->Verical Centers and Horizontal Centers
Theese effectively moves you text inside the Box
Stop recording
 

roschirosch2

New Member
Messages
2
Likes
0
Do you have File->Automate->Fit Image... command?
If you do then record simple action:
Make your text layer.
Duplicate layer to new document(Layer->Duplicate layer...)
In the new document choose Image->Trim. Trim transparent pixels on all sides
Now choose File->Automate->Fit Image... In the dialog enter the width and height of the Box
Edit->Copy
Close new image, this should bring you back to the original image
Delete current layer, you do not need old text
Edit->Paste
Now make selection of the box layer (Ctrl click on it's icon), make sure the text layer is selected in the Layers panel and
choose Layer->Align Layers to selection->Verical Centers and Horizontal Centers
Theese effectively moves you text inside the Box
Stop recording
Thank you so much!!! This worked perfecty! :) I really wouldn't have thought of that!
 

Top