Rails Paperclip Plugin - Style Options for Resizing - ruby-on-rails

So, I want to resize images to a FIXED width, but proportional height.
I have been trying a wide range of operators:
380x242#
380x242>
380!x242
380x242<
none of them have the desired effect. Any help? I want it to fill or resize to the 380 width, then resize / shrink the height by the same factor it used to shrink or resize the image to 380 wide.

Try using 380x
This should resize width to 380px and keep original aspect ratio.
For all available options for resizing images go here: http://www.imagemagick.org/script/command-line-processing.php?ImageMagick=lj6pre8q2iautc3ch6nuph1fc2#geometry

"#" is an argument used by Paperclip to know whether or not you expect the pic to be cropped. Using "100x100#" will scale and crop the picture exactly to that size. %#!<> are arguments in the Geometry String used by ImageMagick. One can use the following ImageMagick geometry strings for resizing images:
Ignore Aspect Ratio ('!')
Only Shrink Larger ('>')
Only Enlarge Smaller ('<')
Fill Given Area ('^')
Percentage Resize ('%')
Pixel Count Limit ('#')
According to the ImageMagick documentation for Image Geometry the geometry argument can be
scale% Height and width both scaled by specified percentage
scale-x%xscale-y% Height and width individually scaled by specified percent
width Height automagically selected to preserve aspect ratio
xheight Width automagically selected to preserve aspect ratio
widthxheight Maximum values of height and width given, ratio preserved
widthxheight^ Minimum values of width and height given, ratio preserved
widthxheight! Width and height emphatically given, ignore original ratio
widthxheight> Change only if an image dimension exceeds a specified dim.
widthxheight< Change only if both image dimensions exceed specified dim.

you can use , :show => '786>x447' for fixed width and prorortional height

The resizing options are limited but you can also use paperclip custom processors to resize images dynamically.
Railscasts has a good example of using a custom processor for paperclip, though his example allows a user to crop an image.
http://railscasts.com/episodes/182-cropping-images

You can calculate the height yourself:
newHeight = oldHeight * 380 / oldWidth

Related

how to make the label proportional to the screen size?

I am a beginner, I am trying to do an autolayout. I am trying to make the label 'HRIS' and 'Please login to continue' to be proportional to the screensize (its superview), I can do it for the login button and the image leaf as the picture above, we can see that the login button and leaf image are proportional.
for the image leaf, I do equal width with 0,1 multiplier to the superview, and then I also add 'aspect ratio' to make it proportional.
but when I apply the same way to the label, it doesn't work, as we can see the label size still the same for iphone 4s and iphone 8, maybe it is because the instrinsict content size (the font size itself) that makes it like that. I tried to apply this way, but it seems the size is still the same
I want to make it little bit smaller for iphone 4s, I also can't modify using size classes since it is in the same class
so what I have to do to make label proportional to the superview (screen size / background) ?
You can do it by setting both proportional width of the label and allow it to scale down the point size.
Set the label width to proportional width like this. It is just a regular same width constraint that you edit.
Then allow your label to scale down the point size like this. This is a property of your label.
Set different font size using variations...
Simply set up a constraint for your label's width to be equal the view's width with your desired multiplier. In my example I used a multiplier of 0.5:

What constraints should be given to increase size of imageview with respect to device screen size without reducing image clarity

I have to show an imageview in a universal app ans it's size should increase as the screen design in every devices without reducing image quality. The image given to the imageview is a static image. If I use static width and height constraints using size classes it will work. But I don't think it as the correct way. If i use width & height
Proportional to the superview, it increases the image height but image clarity reduced in ipads. Any suggestion will be helpfull.
To make Imageviewsize respect to device for universal application , you need to give correct multipler to imageview.
please follow step to get desire output,
Step 1 :- Set Aspect Ratio to your imageview . (you can also set leading and trialing top , bottom etc. and then give aspect ratio.)
Aspect ration required to maintain to set image equal width and Height (Square)
Step 2 :- Set Horizontal center and vertically center imageview . (it will be differ according to your requirement , you can also take this step as step 1 and then set aspect ratio)
Step 3 :- Set Equal height to Superview from imageview.
(Don't panic , you will get warning to update frames or constrain but don't update it)
Step 4 :- Count Accurate Multiplier.
imageviewHeight / superview's height = Accurate Multipliar
Here ,
imageviewheight = 200 , superviewheight=600 so ,
200(imageviewheight)/600(superviewheight)=0.333
(set multipler to imageview where proposanal height = superview)
Step 5 :- check output to different simulator.
I hope this detail explanation is enought to understand your question.
you can give equal height or width with superview with different multiplier. for example multiplier is 0.5 five then your height or width will be half of superview's height.
hope this will help :)
Anchor the edges of the image view as you want. so that the size of image view will change based on device. But set the mode of image view to "Aspect Fit" which will make sure the image will resize but maintain the aspect ratio. You can change mode in Attribute inspector.
Please refer Difference between UIViewContentModeScaleAspectFit and UIViewContentModeScaleToFill?

Xcode 6.3.2 - iOS - Ambiguous UIImageView

I want a UIImageView to expand based on the actual image's height and width. Specifically, I take the image's height and width, and then divide both by ([larger value] / 300) so that the aspect ratio is maintained and the image is optimized to fit in the space I have designed for it (a width that is never smaller than 320 and a height that is always exactly 320). In the code I give the UIImageView the new height and width that I acquired from this procedure. All of this works exactly as I intend it to when viewed in the iPhone Simulator. However, Xcode is giving me warnings about my constraints for the UIImageView, saying that the "position and size" are ambiguous. What is the correct way to make these warnings go away?
Here is the ViewController:
http://i.imgur.com/cVWmVET.png
And here are the constraints I have for the UIImageView in the middle:
http://i.imgur.com/4orUyeh.png
For maintaining aspect ratio and showing image, you don't have to do manual calculations. Just set the following property of UIImageView and assign the image to it
yourimageView.contentMode = UIViewContentModeScaleAspectFit;
For keeping UIImageView in the center of screen, use following autolayout constraints
Constant Height
Constant Width
Horizontal Center in Container
Vertical Center in Container
If you are intending your imageview to expand, then you got to give a bigger values to the Imageview's Content Hugging property,
By Default its 250, give its horizontal and vertical value as 751 as 750 is the default value for Content Compression, so u have to give it a bigger value than that. Tell me if this works.

jassor Increase the width and height of the nested slider

I have downloaded the jassor. The nested slider is the perfect solution for our requirement. But the problem is client need full size images in the slider (90 % height, 100% width of the window). How the size can be changed ?
Please change the size of 'outer container' and 'slides' container.
Btw, jssor slider will always keep aspect ratio while scale.
Reference: http://www.jssor.com/development/tip-arrange-layout-adjust-size.html

Auto width and height with imagemagick?

I'm creating an image of a string of text with imagemagick and I need both the width and height of the image to conform to the size of the text.
Currently, I use the "caption" command and specify a width of 300px, so the image is always 300px wide, and the text wraps if it is longer than 300px.
I guess I would need to still specify a maxwidth somewhere in the imagemagick code, so that the text still wraps at 300px.. but I would like width of the image to fit the longest line of the wrapped text and not be exactly 300px. Is this possible?

Resources