I'm trying to parse the PSD file using PSD.rb gem.
When I'm trying to get the text box bounds, it is giving minimal bounding box for the text, not the actual text rectangle dimensions in the psd file.
Similar issue was posted here: https://github.com/layervault/psd.rb/issues/78
But, there is no proper solution for it. So, can anybody help me in finding the exact text box Bounds from PSD?
Thanks in advance!
Getting Height & Width information from the bounds object:
bounds = layer.adjustments[:type].data[:text]["bounds"]
layer_tree = layer.to_hash
transform = layer_tree[:text][:transform]
top = transform[:ty] + bounds["Top "][:value]
left = transform[:tx]
width = bounds["Rght"][:value]
height = bounds["Btom"][:value] - bounds["Top "][:value]
Thanks.
Related
I am trying to increase the size of an image in a .pdf document using knitr, but when I try to do this the image shifts to the right and off the page. Here is the syntax I am using:
```{r test_image, echo = FALSE, out.width = '150%', fig.align = 'center'}
knitr::include_graphics("test_image.png")
```
I have also tried inserting fig.height and fig.width to adjust the height (instead of using out.width) but I still get the same thing. I have also tried fig.align = 'left' to keep the image on the page but that does not solve the issue either.
Has anyone else noticed this behavior? Is there a way to maintain the image centering when increasing the image size?
My thoughts.
I think, that this problem exists because of "big amount" of whitespace on left and right sides of your picture.
You can trim it manually and add after with knitr::include_graphics or do it with latex straightaway:
Add to your header:
header-includes:
- \usepackage{graphicx}
Add your pic
\includegraphics [trim={5cm 0 5cm 0},clip]{Ml6KL.png}
#you can also customize your width/height
#\includegraphics [trim={5cm 0 5cm 0},clip, width = XX, height = XX]{Ml6KL.png}
An output:
P.S. If you can - try to find better versions of first two logos(or scale < 1). As you can see - the quality leaves much to be desired...
I am trying to round the corners on my UIImageView in tableViewCells, however, for some reason, they are clipped. I have tried this:
cell.characterThumbnail.layer.masksToBounds = true
cell.characterThumbnail.layer.cornerRadius = 15
and this is the result I get:
If I use the debug 3D viewer I get the frame is larger than I've set (I want 84 * 84 but it shows 84 * 110). Shown here:
Why are there different sizes? And why are the rounded corners clipped? I have to point out that the image in the UIImageView is downloaded from an URL for each thumbnail.
Any help on this matter is much appreciated. It has bugged me for a week lol.
P.S. I forgot to mention that I've read almost every single "rounded corner" question here on SO and elsewhere on the internet, but no mention of clipped corners. Also, I have thought about rounding the actual image before displaying it in the UIImageView, but that makes the tableView scrolling jerky.
Edit: Whole project at https://github.com/Aecasorg/WoWilvlChecker
I suspect your image views are set to 'aspectFit', not aspectFill:
You have to set clipsToBounds true and give it a desired radius.
cell.image.contentMode = .ScaleAspectFill
cell.image.layer.cornerRadius = 10
cell.image.clipsToBounds = true
//Use this to add border
cell.image.layer.borderWidth = 3
cell.image.layer.borderColor = UIColor.whiteColor().CGColor
The problem what see is that round corner is getting drawn on 84X110 and not 84X84. That's why it looks strange.
Please call sizeToFit() (this resizes and moves the receiver view so it just encloses its subviews.).
cell.characterThumbnail.sizeToFit()
cell.characterThumbnail.clipsToBound = true
just before
cell.characterThumbnail.layer.masksToBounds = true
cell.characterThumbnail.layer.cornerRadius = 15
However, if you want to keep thumbnail-view fixed 84X84 and resize the image then you need to set aspectFill.
And in the storyboard of (WoWilvlChecker) fix the width and height of the view to 84X84
Also I think cornerRadius not needed to be 15. A value like 3-5 should be sufficient.
I checked your repo.
Remove centerY constraint, it seems centerY is causing this "stretched height" problem.
If you want to make imageView's Size applied,
then set width, height, (centerX, CenterY) or (vertical one, horizontal one)
Project has problems with layout constraints and content mode in the imageView.
Just add height constraint for the imageView and change content mode to Aspect fill.
Also I recommend to use smaller corner radius, for example 5.0. You can exam my changes in the pull request.
It is all due to constraints. All I needed was to get rid of the "Leading Space to: Superview" and "Bottom View to: Superview" constraints I had set up and add an "Align Center Y to: Superview" and that sorted it. Thanks to everyone for responses and suggestions!
I'm trying to get the exactly baseline of a text of a UILabel.
label.frame.maxY returns the max y of the box of the UILabel.
But what I really want is the maxY of the position of the text.
Ignore the "button". I just searched this image from google. I know how to get what the first returns (maxY), but I want to know how to get the second one (where the dashline is under the text).
Thanks for any help!
You can achieve this quite simply :
let baselineY = label.frame.origin.y + label.font.ascender;
I am working on ClosedXML for Export an Excel, and just find a property for alignment Center and CenterContinuous.
worksheet.Column(9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
And
worksheet.Column(9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.CenterContinuous;
I have tried both, but the results remain same, anybody know what the exact difference?
CenterContinuous will center text along cells with same style.
I am having a problem with a UITextField's text being blurred/anti-aliased even with a standard font size. The text will appear crisp when the control is the first responder, but blurred again when it loses focus:
(source: mikeweller.com)
Does anybody know how to fix this?
Use CGRectIntegral to make sure the text fields' frames are based on integer coordinates. You'll get fuzzy antialiasing when things lie on fractional coordinates.
OK I'm answering my own question here.
I found a number of references to this bug through Google, but everybody worked around it by playing with font sizes. After much hunting I found this thread that says anti-aliasing is applied when a view's frame contains fractional pixel values, e.g. if you calculate its size as a fraction of the super view.
Sure enough, casting the CGRect values to (int) for the view's frame worked perfectly. So as an example, if you wanted your text field to be centered vertically in the superview, you should use an (int) cast like this:
textFieldWidth = 300;
textFieldHeight = 31;
offsetX = 0;
offsetY = (superview.bounds.size.height - textFieldHeight) / 2;
textField.frame = CGRectMake((int) offsetX,
(int) offsetY,
(int) textFieldWidth,
(int) textFieldHeight);
There is also the CGRectIntegral function that you can use to convert a CGRect to integral values.
In addition to using non-fractional positioning one should make sure to use a non-centered vertical alignment for the UITextField. Looks like centered vertical alignment in combination with an odd font size results in blurred text, too.
i tried using CGRectIntegral and stuff. In my case changing min font size and font size in IB did it.
I encountered this problem before. The solution below works perfectly for any text or frame size because it uses the round function to get rid of the fractional pixel values. Insert the following code after your instantiation of the uitextfield in question.
CGRect temp = textField.frame;
temp.origin.x = round(temp.origin.x);
temp.origin.y = round(temp.origin.y);
textField.frame = temp;
Simply setting the UITextField frame height to an even value fixed it for me.
Solution from this site explains that it can be related to resizing and iOS does not take care of this bug for layers, only the various views. I updated it to Swift 4:
view.contentScaleFactor = UIScreen.main.scale
I would love to contribute as I just discovered the answer on my own after quite a bit of frustration.
The UITextField in InterfaceBuilder has a forced frame height of 31 pixels. This cannot be click-dragged to resize nor can it be set in the frame properties in IB. You need to go to viewDidLoad and adjust the frame height to 32 pixels, and this should solve the problem.
Hopefully, future versions of IB will correct this.