• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Algorithm for fitting different sized rectangles in a larger rectangle

Community Beginner ,
Feb 08, 2018 Feb 08, 2018

Copy link to clipboard

Copied

I need script an algorithm to calculate best fit for rectangles in a larger rectangle.. and the larger rectangle changes size dynamically.

The dimensions of each rectangle include several 5 * 5 rectangles.

like the picture below.

pleas help me.

11.JPG

TOPICS
Actions and scripting

Views

9.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Feb 08, 2018 Feb 08, 2018

Copy link to clipboard

Copied

First off you may want to post over at

Photoshop Scripting

I need script an algorithm to calculate best fit for rectangles in a larger rectangle.. and the larger rectangle changes size dynamically.

What exactly do you mean, especially by »changes size dynamically«?

And what about the white borders?

Please explain your intention in more detail.

The dimensions of each rectangle include several 5 * 5 rectangles.

Some of the images appear to be square, so what are the images’ proportions?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

i want place images or textFrame in page.Like attached photo.

The dimensions of the document page may be dynamic.example : For the newspaper 50 * 70

For the magazine 30 * 20.

i want script i want place images or textFrame in page.

white borders is margin.

Some of the images appear to be square, so what are the images’ proportions?: example :The dimensions of a 10 × 2 image include 2 number 5 × 2 frame in horizontal direction.That is, each image is measured with a 5 * 2 fram. Please attention to the photo below.

ok?

56.jpg.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

I fail to understand the principles governing the image-placement and -clipping so far.

How many images need to be placed, can certain images be dropped, do they have content that must not be clipped, …?

And as mentioned before you should post on the Scripting Forum.

But this seems like a bad fit of a task for Photoshop – Indesign (or possibly Illustrator) might provide preferable output (especially if texts are involved) and more convenience in image-placement.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

i want place images or textFrame in page.Like attached photo In the previous post.

The dimensions of the document page may be dynamic.example : For the newspaper 50 * 70

For the magazine 30 * 20.

i want script i want place images or textFrame in page.

white borders is margin.

Some of the images appear to be square, so what are the images’ proportions?: example :The dimensions of a 10 × 2 image include 2 number 5 × 2 frame in horizontal direction.That is, each image is measured with a 5 * 2 fram. Please attention to the photo below.

ok?

56.jpg.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

giude me.

And as mentioned before you should post on the Scripting Forum.?

My description was obvious.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

My description was obvious.

You think so?

You did not make clear how many fields are indispensably necessary, how many images have to be placed, how the image can be clipped, … 

And as mentioned before you should post on the Scripting Forum.?

In post 1 I provided a Link to the Photoshop Scripting Forum:

First off you may want to post over at

Photoshop Scripting

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

The image should not be clipped.

jast place in page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

Hi

I've moved your post to the Photoshop Scripting forum

Dave

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

How do I do this?

I do not know.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

Please give a meaningful description of the intended process.

The numbers in your screenshot from above (2x5, 4x5, 2x10) seem to disregard the gutters so if your images actually had those proportions (2x5, 4x5, 2x10) they would clash with the grid or have to be clipped. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

Please provide an algorithm for arrenging photos of different dimensions.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

I do no thinhk think you have a claer idea of what you want to do.Even undestand that if you want to fit an image to an area without distortion if the image has a different aspect ratio than the area the resize image will not fill the area. You are not going to be able to place image with random aspect ratio neatly like you show here:

11.JPG

Even in the example you show here it looks like the images have been resize to fill the areas  and the excess masked of to constrain the image to the areas. So the image compositions have been changed to a virtual centered crop the aspect ration of the different image areas aspect ratio.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

no . No . it is not like this.

pleac chek this link:
https://forums.adobe.com/thread/2449915

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

no . No . it is not like this.

I for one still do not fully understand your proposed rules governing the placement of images.

So instead of claiming you made your point maybe you should try to make it more clearly.

What are the  actual dimensions of the images that are to be placed?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

Their original dimensions.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

Please look at this picture.

1.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

It is easy to make template for  media that have different size pages.  However you are not going to be able to layout images with different random aspect ration neatly in some matrix of images in an orderly fashion.   If you fit images to an area there will be aspect ratio mismatches leaving white space on at least one image side you will not have the same border around all images.  If you fill an area and mask excess off the images compositions will be cropped and if the aspect ratio change is great the resulting composition will most likely not be acceptable.    You have been asked to be more specific about what you actually want to do and for image can have any aspect ratio image can be resize uo or down in size  they will still have their original aspect ration and very like not match the area you want to position it to aspect ratio.   Here you show I tiled layout where  one 4x5 fills 2 2x5 areas plus the gap between the 2 2x5 areas How do you purpose to do change the 4x5 height to larger then 4 and not distort the image. Also show a 2x10  being stretched wider than 10.  You do not have a good understanding of what you want to do.  Do not care about what you don't have care about what you do have and what you want to do with what you have. Right not what you show would distort your images streatching them that way.

56.jpg

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

No . I do not know why you do not understand.

It's easy.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

Please look at this picture.

1.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

shahriara7551080  wrote

Please look at this picture.

1.jpg

OK I will agree that the frame pointed to with the red arrow is const  whatever  you define const to be it is what it is..  I do not agree that the other frame are like your const frame other than they are rectangular. They are different in size and aspect ratio. Only images with matching aspect ratio can be perfectly fitted into a frame.   The frame opening aspect ratio and the images aspect ratio must be a perfect match.  The example red arrow is point to an inner 2*5 frame that is different in size than your const red arrow frame.  the margins between frames differ.  The only  common thing I see is all frame are rectangular and some frames have side the same length as some other frames. The height of all may be a multiple of 2 but the width of all are not a multiple of 5 because the margins between frames in the layout are not a multiple 5.  The bottom frame is noted as 2*12  it spanning 4 upper frames. if the upper frame are 5 wide the  bottom frame is over 20 wide you do not understand what you want to do so it impossible for you to tell up what you want to do. Even you example is incorrect it is inconsistent.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

Sorry

The bottom frame is  2*60

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

You assume that all margins are equal.

And all rectangles are composed of a rectangle of 2 *5

ok?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

shahriara7551080  wrote

You assume that all margins are equal.

And all rectangles are composed of a rectangle of 2 *5

ok?

If all framed images are (some multiple of 2) x (some multiple of 5) in size as you show. All image would not have a 2:5 aspect ratio and most likely image in you would get would not have matching aspect ratios and even if they were most likely you could not layout a random numbers out in a somewhat symmetric layout that forms a rectangle. Like your example form a rectangle.  You could not Handle most standard image sizes with aspect ratios of 2:3, 5x7 etc.  About the only standard size you will be will have a 4:5 aspect  ratio, 4x5, 8x10, 16x20 etc. You need to specify exactly what you want to do and what you want to do must also be possible.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 09, 2018 Feb 09, 2018

Copy link to clipboard

Copied

My problem is like tiling.But easier.

Can you give me a tiling script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines