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

Algorithm for fitting different sized rectangles in a larger rectangle

Community Beginner ,
Feb 08, 2018 Feb 08, 2018

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
9.7K
Translate
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 09, 2018 Feb 09, 2018

shahriara7551080  wrote

My problem is like tiling.But easier.

Can you give me a tiling script?

Tiling is easy you are right. Tile are uniform in  size or there a pattern of different size tiles you follow to fill the rectangular wall space. area the matches a possible tile layout size that matches  the wall aspect ratio and size. Otherwise you need to use a tile cutter. I have made a tiling script available . Its not what you want.

What you are trying to do is more like making a puzzle the solution fit a wall rectangle. Will they even fit well.  How do you do that? When tile size and aspect ratio vary and you have no designed tile pattern.  What do you do  if you have too many or too few image for the rectangle wall space. Do you use a tile cutter or use a lot of filler grout.

Fitting image to a know tile layout is also easy if you will be satisfied with image that have been resize and may have some lost content.

It hard to deal with the unknown. You need a design plan to handle the number of image you are going to use.   Know how many image  know the different image sizes and the number of each different size image so you can calculate there total surface  area and then try to come with a tiling pattern that will result in a rectangle being file the will fit within  the rectangle wall space then adjust spacing to fill the wall space size.  What you want to do is far from easy.

JJMack
Translate
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

Do you even know coding?

Translate
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

I hack at Photoshop scripting it is easy to see you do not know Photoshop well and know nothing about programming so can not script Photoshop.   Here is a link that describes a script  I made avaible as part of my Photoshop Photo Collage Toolkit.  It tiles images.

Paste Image Roll script and Picture Package support documentation

JJMack
Translate
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

i want this script indesign .

Translate
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

shahriara7551080  wrote

i want this script indesign .

Why are you posting you request in Photoshop scripting forum then?

JJMack
Translate
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

Re-explain the issue?

Translate
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
Translate
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

shahriara7551080  wrote

Algorithm script for fitting different sized rectangles in a larger rectangle

Can only be done perfectly if the image and the larger rectangle has the same aspect ratio as the image. You can not fit a square peg into a rectanular farme that does not have a square aspect ratio perfectly  there will be borders or distortion or content loss.

JJMack
Translate
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

I do not want to fit the square into the rectangle.

i want place text frames in page indesign.(like tailing)

This is done before.But I do not know its algorithm.

Translate
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

Why are you using the Photoshop Scripting forum then?  I have no idea what a text frame is even In Photoshop we have text  boxes that text will flow in like align like paragraph How nuch text will fit is a function of font size and box shape and size not always a rectangle or squared with the canvas.  Where would text frames come from? You should try using the indesign scripting forum InDesign Scripting

JJMack
Translate
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 10, 2018 Feb 10, 2018

A general question:

​Is it possible to place images of different dimensions without cutting it in the page?

Is there such an algorithm?

Answer yes or no

like the picture below

11.JPG

Translate
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 10, 2018 Feb 10, 2018
LATEST

If you have a tiling template like you show hear and you have the correct number of high resolution image with matching aspect ratios for the different tile locations  You could resize the images for their tile location with matching aspect ratio.  If you resize an image without distortion the resize image Aspect ratio will not Change.

However, you will loose some image quality.  If you resize an image down in sized  so it has fewer pixels you have to through away some details you have in the original image size you do not have the space required to store all the image detail you have. If you increase the images sized you have to add  additional pixels.  You do not have details for the added pixels.  So details need to be added.   When you resize a raster image the existing pixels are interpolated to produce pixels for the resized Image.  There are many interpolation algorithm which one will work best often depends on image content.  IMO Bicubic is the best general purpose one.   Larger size changes loose more image quality than a small size change.   When you reduce and image is size the resized images tend to look sharper than the original size image,  Image increased in size tend to look softer less sharp.  If you start with high resolution high quality image you resize image quality should be very acceptable.

However, what you want to do with a random number of different aspect ratio image being neatly tiled is far from easy not easy like you wrote.  In fact I do not know it there is a general solution.  I have never seen one written about but  I'm not a big reader there may be one. I know developing such a process is beyond my abilities.

JJMack
Translate
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

My output looks like a picture. Exactly .

Can you give me this script for me?photo_2018-02-09_22-18-57.jpg

Translate
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 10, 2018 Feb 10, 2018

Photoshop and Indesign have different design points. They may compliment each other. Indesign is a tool design creating for publication while Photoshop is a tool for  Image editing.   Publication publish Image as well as text so I'm sure Photoshop would also be a useful tool for publication.  However, Indesigh  I am sure  has better tools and features for layouts then  Photoshop.  I am willing to bet the like in Photoshop there is a big difference between text and Image.  You use different tools for editing and resizing text and image and they are resized very differently.  I would think the proper application for what you want to do would be Indesign.  I can not help you with Indesign for I do not use it and All my scripts use Photoshop DOM not Indesign's DOM.  IMO you should use the Indesign Scripting forum for your topic. Image resize via interpolation text is resize via vector graphics if you rasterize  text and resize it using interpolation the resize text quality will not be acceptable.

JJMack
Translate
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 10, 2018 Feb 10, 2018

Do  you know the  indesign script?

Translate
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 10, 2018 Feb 10, 2018

I wrote   I can not help you with Indesign for I do not use it and All my scripts use Photoshop DOM not Indesign's DOM.  IMO you should use the Indesign Scripting forum for your topic.

JJMack
Translate
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 10, 2018 Feb 10, 2018

ok .

tankss

Translate
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

i want place text frames in page indesign.

There may be an GAP between the text frames.

The next step is filled with default text frames.

Give me a script that puts images in different sizes(The dimensions of the images are proportional to the page.That is, do not cut the images) on the page.

tanks.

Translate
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

pleas help me.

Translate
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

We are trying to help you.  You do not understand what we write.  There is a communicating problem. You need to try to understand what user have written to you.

JJMack
Translate
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
Advocate ,
Feb 10, 2018 Feb 10, 2018
Translate
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
Advocate ,
Feb 10, 2018 Feb 10, 2018

geppettol66959005​

He wanna do this in Indesign

InDesign Scripting

Translate
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